views:

69

answers:

3

Hello, I need to ask: I use Forms Authentication in my ASP.NET application.

but when I publish the web after the user login, if he didn't signout he just close the browser and after that he browse it again it will redirect him to default page. How can I enforce redirecting him to the login page even if he didn't sign out?

A: 

It will depend on whether or not their asp.net session id cookie still exists, or whether they have cookies enabled at all. To enforce redirecting to the login page you will need to find out how to make the cookies be lost when the browser is closed. In my experience this is the default behaviour anyway.

mrwayne
In fact i noticed that its work correct when I run the application under visual stdio .net but when I publish the web and the user close the browser without logout it redirect him to default page
wafa
A: 

I will suggest you to check asp.net Membership,Profile and Role provider for specifically manage user Logins, Passwords and their profile.

This is one of the good articles from Scott Gu, you should bookmark when you want to work with Membership and Profiles.

Mahin
+2  A: 

You should see the documentation for forms authentication specified here. You can force the cookies to expire whenever you want setting the timeout attribute. Also, you could not use cookies at all by using the cookieless attribute. There are other optional attributes that could be useful for you, that might not be related to your question as well.

Raúl Roa