Hi everyone,
May i know that how to validate user whether login or havn't login from the default.aspx.
Using Session?
If Session("Username") = "" Then
Response.Redirect("Login.aspx")
End If
or is there anyother way??
Thanks
Hi everyone,
May i know that how to validate user whether login or havn't login from the default.aspx.
Using Session?
If Session("Username") = "" Then
Response.Redirect("Login.aspx")
End If
or is there anyother way??
Thanks
If you use the above method, you need to check this validation in each and every pages of your web application. To avoid this, create a Base Page class which is inheritated from System.Web.UI.Page. All your pages(except login page) in your web application should inherit from this base page. Therefore you can write the above code to validate the user login in the page load event of the base page class. This code will be executed for all pages whenever the user access a page without login.
Alternatively, you can implement ASP.NET Forms Authentication and it will automatically redirect to login page if the user access any of the page without log-in.
To know more about forms authentication, visit the following links
http://msdn.microsoft.com/en-us/library/aa480476.aspx
http://www.exforsys.com/tutorials/asp.net-2.0/forms-authentication-in-asp.net-2.0.html
http://www.codedigest.com/Articles/ASPNET/112_Implementing_Forms_Authentication_in_ASPNet_20.aspx
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.