Database Storage with the ASP.NET Web Matrix: Simple Login Page - Do you want to use a template?
(Page 5 of 5 )
The Web Matrix does provide a login page template under the Security templates section, but I thought that creating the page manually may help to promote a fuller learning experience. If you create a new page from this template, you will see that in the Loginbtn_Click event handler that comes as part of the template, a line of code that reads:
FormsAuthentication.RedirectFromLoginPage(UserName.Text, true)
This line of code would be used instead of the Welcome message we created. What this does is either redirect the user to the page that the user was on before the login page, or redirect them to their default page. The second parameter of the method states whether a session persistent cookie should be created or not. I have left this out of this tutorial because so far, all we have is a registration page and a login page; there is no default page that you could be redirected to!
So far, you have seen how easily and quickly pages can be created with the power to insert and read data to and from a database. The next articles will describe how the Web Matrix can be put to the task of removing and updating data from a database, so pretty soon, you should have a good understanding of just what can be achieved with a data-driven ASP.NET site.
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |