.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> ASP.Net >> Post New QuestionBookmark and Share Subscribe to Forum

How To Auto Login into the WebSite

Posted By: Santosh     Posted Date: February 22, 2010    Points:2   Category :ASP.Net
hi
can any body plz tell me how to Auto login a WebSite.
means when i run the application,it Automatically login into the website.

Regards
Santosh

Responses
Author: Praveen          Accepted Answer   
Posted Date: February 22, 2010     Points: 10   

Hello Santosh,

Use cookies to save username and password and while loading the web page (Page_Load event) check the cookies first whether it exist or not if cookies exist than take the value from this cookies and validate.

And in successful authentication redirect to whatever page you want.

Author: Lalij Mer             
Posted Date: February 22, 2010     Points: 5   

Use this code sample to using the ASP.Net Membership and FormsAuthentication an easy way to do auto-login is the following code

string userEmail = "abc_xyz@gmail.com";
string password = "thepassword";
if (Membership.ValidateUser(userEmail, password))
{
FormsAuthentication.SetAuthCookie(userEmail, true);
Response.Redirect("~/");
}


show here another details

http://www.experts-exchange.com/Programming/Languages/.NET/Visual_Basic.NET/Q_23418704.html

Please Check my answer if you help....
Thank You...

Lalit.
Author: Santosh             
Posted Date: February 22, 2010     Points: 5   

hi praven
can u plz send me code.


regards
santosh

Author: Santosh             
Posted Date: February 22, 2010     Points: 5   

hi lalit
ur code is not working.

Thanx
Santosh

Author: Amit Mehra             
Posted Date: February 22, 2010     Points: 5   

HI Santosh,

To save the user name and password in the cookies you can try like this

HttpCookie myCookie = new HttpCookie("myCookie"); //Create the instance of HttpCookie class

myCookie.Values.Add("username", "MyUserName"); // Add Key and its value to Cookies

myCookie.Values.Add("password", "MyPassword"); // add Another key and value.


To Retrive the value from the Cookies try like this

HttpCookie cookie = Request.Cookies.Get("myCookie");

string UserName = cookie.Values["username"];

string Password = cookie.Values["password"];


Hope this will help you.

Thanks,
Amit
Please "Mark As Answer " if this post help you.


Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend