1

My Asp.net Session Expires immediately even though i did the settings in web.config file,

<system.web>
        <sessionState timeout="2880" mode="InProc" cookieless="UseCookies"></sessionState>
        <customErrors mode="RemoteOnly"/>
        <trace enabled="false" localOnly="false"/>
        <compilation debug="false" strict="false" explicit="true" targetFramework="4.0"/>
        <httpCookies httpOnlyCookies="true"/>
        <pages validateRequest="false" enableEventValidation="false" viewStateEncryptionMode ="Never" enableViewStateMac="false" />
    </system.web>

i did above settings in web.config even then it expires after approx 3 minutes... can anyone help me??

Yahia
  • 69,653
  • 9
  • 115
  • 144
Puneesh
  • 11
  • 2

2 Answers2

0

Remove the cookieless attribute if your application is AJAX-Enabled. Use default value of cookieless attribute.

From MSDN doc:

The cookieless attribute can be one of the following possible values. The default is the UseCookies value.

Note: When you configure an AJAX-enabled ASP.NET Web site, use only the default value of UseCookies for the cookieless attribute. Settings that use cookies encoded in the URL are not supported by the ASP.NET AJAX client script libraries.

KV Prajapati
  • 93,659
  • 19
  • 148
  • 186
0

I believe session does not expire immediately, but simply die. Since you are using InProc session state it could die whilst

  • Any change to the web.config file cause AppDomain unload and session as well
  • Application Pool restart. InProc session satte pretty risky thing, I would suggest at least allocating separate Applciation Pool for each web-site
  • Any code changes in code behind files cause AppDomain unload (and session as well) in order to load new assemblies in a new AppDomain

The best solution - use SqlServer Mode session state.

sll
  • 61,540
  • 22
  • 104
  • 156
  • i cannot use sqlserverto store session state i don't have access to admin rights of online sql server, i need to do it by other means.. – Puneesh Nov 16 '11 at 10:54
  • @Puneesh - is it hosting company? You can ask to setup this feature for you. At elast ask whether your site has own app pool – sll Nov 16 '11 at 10:59
  • SQL Server isn't necessarily the "best" solution. It's the most robust solution. I would go for State Server mode at the minimum though, and that doesn't need a SQL Server to host it. – starskythehutch Nov 16 '11 at 11:21