IIS 7.5 AppDomain recycle causing losing session after adding virtual directory to ‘Default Web site’

application-poolsiis-7.5virtual-directory

I hope you can help me out here, because i tried to get some answers already in another board (see here) This Question is build on a reply of Scott Forsyth here.

When adding a new virtual directory to the 'default web site' in IIS Manager, all the other Applications located in the default web site are recycled somehow. In order to simplify my problem, i took an example where i could track a timestamp from an current session and realized that the session information is really getting lost after adding a VD, meaning the AppDomain was recycled.

This is the situation:

Sites

Default Web Site

    1 (virtual directory) (d:\TestAppDomains\1\)

       - app1 (Application)           (using App Pool 1)

    2 (virtual directory) (d:\TestAppDomains\2\)

       - app2 (Application)           (using App Pool 2) 

As far as i understood adding a virtual directory is just making changes to the applicationHost.config, which should not cause the AppDomains to recycle. Maybe it is a delegation issue, but i guess i dont get it enough to understand 🙁

Are there any properties which affect this behaviour? I´ve already set the AppPool settings to not recylcing after a configuration change, but it didnt help.

I would REALLY appreciate if you could help me out with this one, because i am struggling with it for almost 6 months now.

Of course i´ll gladly provide more information if you need them.

Update 1:

The HealthMonitoring cannot help me out on this one for two reasons:

  1. Cannot find any entry for AppPool recycle, where should it be? Event Viewer -> Windows Logs / Application and Services Logs? (Should be configured properly)
  2. Maybe i got something wrong. First i thought it is an app-pool recycle but with the simplified test i build an example without any applications and additional app-pools. Now it just looks like this:

Sites

Default Web Site

    1 (virtual directory) (d:\TestAppDomains\1\)          
           session1.aspx (Sets current timestamp to session variable and redirects to session2.aspx)
           session2.aspx (displays session variable)

By calling the localhost/1/sessions1.aspx i can see the timestamp. After adding a second virtual directory (e.g. "2" (d:\TestAppDomains\2)) and refreshing the page the session is gone, meaning the variable is null.

Cheers, Adam

Best Answer

I had the same situation as you described at IIS forum: one web site, several application pools, several pairs of Applications (web-service) and Virtual directories (html + js), automated deployment and so on.

The problem was the same: when I added/removed virtual directory, all applications restarted. This was not good as I planned to serve multiple versions and wanted users to work while fresh version was deployed.

I've played with settings delegation with no success. Then I noticed that adding/removing of one Application didn't led to the restart of others.

So, this was the solution: create for web pages separate Application instead of Virtual directory.