| Author: Meetu Choudhary 16 Oct 2008 | Member Level: Gold | Rating: Points: 1 |
Please use form authentication and there you can provide the access to different users and for different folders or files using roles...
== Thanks and Regards Meetu Choudhary
|
| Author: gomathinayagam 16 Oct 2008 | Member Level: Gold | Rating: Points: -8 |
add form authentication in web config. that will help to do these all things.
in web config :
<authentication mode="Forms"> <forms loginUrl="Login.aspx" name="sqlAuthCookie" defaultUrl="Home.aspx" timeout="60" path="/"> </forms> </authentication>
<authorization> <deny users="?"/> <allow users="*"/> </authorization>
in login page login button click event after password verified:
FormsAuthentication.SetAuthCookie(this.txtUserName.Text.Trim(), false); FormsAuthenticationTicket ticket1 = new FormsAuthenticationTicket(1, this.txtUserName.Text.Trim(), DateTime.Now, DateTime.Now.AddDays(2), false, "user"); HttpCookie cookie1 = new HttpCookie(FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(ticket1)); Response.Cookies.Add(cookie1); string returnUrl; if (Request.QueryString["ReturnUrl"] == null) { returnUrl = "Default.aspx"; } else { returnUrl = Request.QueryString["ReturnUrl"]; } Response.Redirect(returnUrl);
|
| Author: Nagarajan 16 Oct 2008 | Member Level: Gold | Rating: Points: -20 |
TRy using forms authentication
Forms Authetication is a cookie based authentication system where the username and passport is stored in a database
Define your web.config as below
configuration> <system.web> <authentication mode="Forms"> <forms loginUrl="login.aspx" protection="All" timeout="30"> </forms> </authentication> </system.web> So, when you the user is not authenticated and if he is trying to access as page, then the page gets redirected to login page, defined in web.config.
You can check authentication in login page and redirect from the it as below
if (FormsAuthentication.Authenticate(txtUsername.Text, txtPassword.Text)) { FormsAuthentication.RedirectFromLoginPage(username.Text, true); } else { // Do Something for invalid login }
Hope below url would help you setting up forms authentication with SQL
How To: Use Forms Authentication with SQL Server in ASP.NET 2.0 http://msdn.microsoft.com/en-us/library/ms998317.aspx
Also to get a good knowledge on Forms Authentication try the below url too Explained: Forms Authentication in ASP.NET 2.0 http://msdn.microsoft.com/en-us/library/aa480476.aspx
Hope this helps Happy Coder
|