Alper
Alper

Reputation: 1403

ASP.NET Application Restarts Too Much

I have an ASP.NET WebSite which restarts in every 1-2 hours in a day so sessions and other thing are gone and users are complaning about it, because they open a page and do something for 20 minutes and when they submit it, a nice "we are sorry" page is there.

I don't do anything which restarts the application (changing the web.config, changing the files, or even other buggy things like deleting a folder in App_Data which normally shouldn't cause a restart).

Can it be related with Server's hardware? It is not much powerful.

Upvotes: 3

Views: 4605

Answers (8)

Marc Gravell
Marc Gravell

Reputation: 1062865

App pools in IIS get recycled by default - either after a timeout, or after "n" hits.

This should be expected, and is part of the normal processing (although it can be disabled in the app-pool configuration; IIS6 | IIS7).

The fact that this breaks your app suggests that you are using a lot of things like in-memory sessions. Consider moving these to database backed implementations. Apart from withstanding both app-pool restarts and server reboots, this can allow you to scale the site to multiple servers.

Upvotes: 3

pyrocumulus
pyrocumulus

Reputation: 9290

Are you sure that the ASP.NET application actually restarts? Or do you think that it happens because of the lost Session and such?

What is your application's (and IIS') Session timeout variable? The default value of the timeout is 20 minutes, so that's why I am asking. You can set the timeout in your web.config as follows:

<system.web>
    <sessionState timeout="120"/>
</system.web>

But apart from that, there are also places inside IIS itself where you can set it. In the case of IIS6 those places are:

  • Properties of a virtual directory > Home Directory (tab) > Configuration (button) > Options (tab) > Session timeout
  • Properties of a virtual directory > ASP.net (tab) > Authentication (tab) > Cookie timeout

I'm not sure whether or not both are actually needed, but I usually set both to the same value as I set it in my web.config.

Upvotes: 1

Rune Grimstad
Rune Grimstad

Reputation: 36310

Check this blog post about some possible causes for appdomain recycles. There are many possible causes.

If you are unable to fix the problem you could switch from in-process session state to eiter a session state server or to storing session state in a database. Both options are easy to set up and works quite well, but there is a performance impact (between 10-20% I think). There is a nice article here about how to setup a session state server.

Upvotes: 2

Eoin Campbell
Eoin Campbell

Reputation: 44268

Do you have any anti-virus software running on the server. A change to the web.config will cause your application to restart afaik so in some instances anti-virus software passing over the web.config might alter the attributes on the file which could be causing the reset.

Try disable any AV software or exclude the web applications directory from the AV auto scanning.

Upvotes: 0

JP Alioto
JP Alioto

Reputation: 45117

Since you mention that your server is small, you might check to see if your worker process is consuming more memory that you have set in your processModel in machine.config. That can cause a reset.

Upvotes: 1

Chad Grant
Chad Grant

Reputation: 45382

Sounds like the app is being recycled or process is failing.

Check app pool settings http://msdn.microsoft.com/en-us/library/aa720473(VS.71).aspx

and event viewer.

Upvotes: 1

Anton Gogolev
Anton Gogolev

Reputation: 115751

I guess this is recycling.

Upvotes: 4

benophobia
benophobia

Reputation: 771

Is there any indication of the cause of the restart logged in the Event Log?

Upvotes: 0

Related Questions