views:

74

answers:

4

I have a problem with timeout.

firstly the timeout happens every 20 minutes on server even if the time in webconfig is set to 120 mins.

second, when the timeout happens it goes to the login page, which is correct but on logging back in it sometimes goes to the default page and sometimes to the page it was previously on. I want it to go to the default page everytime. Like it should remove all the sessions and cookies if thats the problem.

<authentication mode="Forms">
 <forms loginUrl="Login.aspx" defaultUrl="~/Default.aspx" name="GUI"   slidingExpiration="true" timeout="120" path="/">
</forms>
</authentication>
 <authorization>
 <deny users="?"/>
    <allow users="*"/>
 </authorization>

<sessionState mode="InProc" cookieless="false" timeout="120"/>

This is what is there in my webconfig.

Thanks..

+1  A: 

Check the following things:

  • You've definitely got 120 mins in your web.config?
  • Is this your only web.config? If not is it picking these values up from the correct place?
  • Use fiddler (or similar) to check your browser is still requesting with a cookie (especially after 20 mins)

Other than that I have no suggestions, parhaps your 64% accept rate is putting people off.

m.edmondson
yea sorry made that change...
I think the 120 min problem is because of the IIS on the server.. i am doing my research but if you have any idea please let me know.. thanks.. is 64% really that bad...?/
@user175084 - 64% not necessarily that bad, just trying to think why more haven't answered your question
m.edmondson
hmm.. how do i force it to come to the default page and not go to the page it wa on before the timeout happened. thanks
I think you want to do something like check a session variable on page load, if its null (because they timed out) then response.redirect(default.aspx)
m.edmondson
@eddy, I caution against placing *too much* emphasis on acceptance rate. a) This rate isn't particularly brutal. b) There is no guarantee that you will receive an "acceptable" answer, particularly as questions are more and more associated with specific applications. If, for example, you have 100 questions about Sharepoint, and never get more than 1 or 2 answers, none being upvoted all that much, who's to say what a good acceptance rate actually is?
Anthony Pegram
@Anthony Pegram - Comments taken on board
m.edmondson
+1  A: 

My understanding is that with the setup you described ASP.NET doesn't allow unauthenticated web access to your site. This means that when you go to WebForm1.aspx you get redirected to the login page with this url

/login.aspx?ReturnUrl=%2fWebForm1.aspx

Then in your login page you might have something like this

    protected void LoginButton_Click(object sender, EventArgs e)
    {

        if (FormsAuthentication.Authenticate(UsernameTextbox.Text, PasswordTextbox.Text))
            FormsAuthentication.RedirectFromLoginPage(UsernameTextbox.Text,false);
        else
           // Let the user know they didn't authenticate

   }

This redirects back to whatever the ReturnUrl specifies.

Well if you don't want that to happen don't do that. Do something like this instead.

    protected void LoginButton_Click(object sender, EventArgs e)
    {

        if (FormsAuthentication.Authenticate(UsernameTextbox.Text, PasswordTextbox.Text))
            Response.Redirect("default.aspx");
        else
           // Let the user know they didn't authenticate

    }
Conrad Frix
this might just be the answer for my default page problem.. let me check...
+3  A: 

This may or may not be related to your specific issue, but in-proc user sessions will not survive application recycles. Check in IIS that your application recycle time is sufficiently high. Your sessions may indeed last 120 minutes if the application remains active, but once it idles for too long, your app will recycle and your user sessions will become invalidated.

Anthony Pegram
+1  A: 

Hi Take a look at the application pool in iis, check the advanced settings->process model->idle timeout (minutes). Set this higher than 20 mins. Sounds like the worker process is shutting down because its idle. Often this happens with test systems because they don't get that many hits to stop the idle timeout from kicking in.

Cheers Tigger

Tigger