I think for small web application with a few number of application users, storing login credentials in Web.Config file of the web application should be okay, this may not adhere to .Net Web Application best practices but using a database doesn't make sense. I tried reading encrypted login data from a file but it didn't seem like very portable. For some reason, storing login data in Web.Config looks perfect. So here is how you do it:
1- Open up the Web.Config file of your ASP .Net Web Application
2- Scroll down until you see the xml Authencation tag.
3- Change that to XML below, please use the valid "<" ">" for xml tags. I have used "[" "]" because blogger wouldn't allow me to display XML on pages.
[authentication mode="Forms"]
[forms loginUrl="default.aspx"]
[credentials passwordFormat="Clear"]
[user name="familyguy" password="peter" /]
[/credentials]
[/forms]
[/authentication]
But for this work, you need to make some more changes to your .Net Class code which controls the behavior of your Login page. But before I go ahead and show the authentication code, the:
username is : familyguy
password is : peter
Following is what I added to my C# code that controls the ASP Login page
if (FormsAuthentication.Authenticate(usernametextbox.Text, passwordtextbox.Text))
{
Response.Redirect("profile.aspx");
}
The first line of the C# code is the method call which returns a boolean. The method takes in username and password entered by the user in the textboxes (input controls) on the login pages, as input parameters.
If the correct username / password, familyguy / peter, is entered, user will gain access to the next page which is "profile.aspx" in my application. Response.Redirect("profile.aspx") in the body of the IF condition of the C# code is responsible for loading the next page in the browser.
username is : familyguy
password is : peter
Following is what I added to my C# code that controls the ASP Login page
if (FormsAuthentication.Authenticate(usernametextbox.Text, passwordtextbox.Text))
{
Response.Redirect("profile.aspx");
}
The first line of the C# code is the method call which returns a boolean. The method takes in username and password entered by the user in the textboxes (input controls) on the login pages, as input parameters.
If the correct username / password, familyguy / peter, is entered, user will gain access to the next page which is "profile.aspx" in my application. Response.Redirect("profile.aspx") in the body of the IF condition of the C# code is responsible for loading the next page in the browser.





8 comments:
Hi! Your blog is simply super. you have create a differentiate. Thanks for the sharing this website. it is very useful professional knowledge. Great idea you know about company background.
Customized application development
hello... hapi blogging... have a nice day! just visiting here....
Download Forum Poster V3 3.0 at FileAfro.com
http://www.fileafro.com/view_forum-poster-v3-30.html
hello... you may submit this blog to my webBlog Directory, keyworddir.info.. have a nice day!
Keyword Directory
Watch Natsha Naked!
hi... just dropping by!
http://www.fileafro.com
http://mobileandetc.blogspot.com
http://kantahanan.blogspot.com
hi.. just dropping by here... have a nice day! http://kantahanan.blogspot.com/
Hi... Looking ways to market your blog? try this: http://bit.ly/instantvisitors
Post a Comment