0

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

2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by Ramesh S
0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.