views:

62

answers:

1

I am experiencing a request timeout from IIS when I run a long operation. Behind the scene my ASP.NET application is processing data, but the number of records being processed is great, and thus the operation is taking a long time.

However, I think IIS times out the session. Is this a problem with IIS or ASP.NET session?

Thanks in advance

+2  A: 

If you want to extend the amount of time permitted for an ASP.NET script to execute then increase the Server.ScriptTimout value. The default is 90 seconds.

For example:

// Increase script timeout for current page to five minutes
Server.ScriptTimeout = 300;

This value can also be configured in your web.config file in the httpRuntime configuration element:

<!-- Increase script timeout to five minutes -->
<httpRunTime executionTimeout="00:05:00 
  ... other configuration attributes ...
/>

If you've already done this but are finding that your session is expiring then increase the ASP.NET HttpSessionState.Timeout value:

For example:

// Increase session timout to thirty minutes
Session.Timout = 30;

This value can also be configured in your web.config file in the sessionState configuration element:

<configuration>
  <system.web>
    <sessionState 
      mode="InProc"
      cookieless="true"
      timeout="30" />
  </system.web>
</configuration>

If your script is taking several minutes to execute and there are many concurrent users then consider changing the page to an Asynchronous Page. This will increase the scalability of your application.

The other alternative, if you have administrator access to the server, is to consider this long running operation as a candidate for implementing as a scheduled task or a windows service.

Kev
Thanks Kev. I will give some of your suggestions a try.
Tachi