We have an application where we are changing from in proc session to state server. We recoded the necessary serialisation and enabled the state server process. When we run the app and take pages we can see the state server memory usage grow as session data
is created. App works fine.
Problem is that when we recycle the pool, session data is lost (same as if it was using in-process) This happens on our test and production servers (2008R2) and also on a Win7 VS2010 devenv local iis. However we have another VS2010 in a contractor where
the session is retained through the recycle, like it should be.
After many hours playing spot the difference between the two machines we can not find any ideas about what may be the difference that causes the problem.
The differences we know between the two environments are few. One is in AD domain and the (working one) is not. Pool identity is AD account in non working but local machine account in working. In non working sql is remote, in other it is local. We have switched
web.config files between the environments, but to no avail.
I was hoping if someone has a check list of reasons why session could be lost during a recycle, as this is not expected behaviour.
When you set the sessionstate to stateserver mode, session should be maintained out of worker process, namely stored into aspnet_state process. If you recycle the application pool/worker process, the Session should not be lost. I test this session mode,
all work fine like it should be. For you odd issue, it's difficult to locate what causes lead to session losing. Because the session is saved into aspnet_state process, you may confirm whether this process is disturbed/broken when you recycle the application
pool.
Seem all your configuration is no problem. Now I suggest you to create another simple web site using stateserver mode to test again. If it works fine, that proves the web site occured session losing has some error configuration. To configure SessionState
correctly please check this reference:
I did not find the answer to this yet. I tested by changing session state to sql. This worked as expected, we could see the sql data going in and out and could recycle the app pool without any problems for an open client.
Can you advise what we can do to "confirm whether this process is disturbed/broken when you recycle the application pool".
Can you advise what we can do to "confirm whether this process is disturbed/broken when you recycle the application pool".
I mean you need to confirm whether the aspnet_state process works fine. For me, I create a simplest sample site to test stateserver mode of sessionstate, just a default page and web.config file, default page sets/gets the session. When I set the sessin and
then recycle the application pool, I can retrieve the session set previously. As I suggest you before, try to create another simple site test again:
I think I have found the problem. The recycle started working correctly when I changed the account of the aspnet state service from Network service to be the same as the domain account that is the identity of the app pool.
I don't know if this is the best solution. When I added this account is automatically added the right of Logon as a service, which we did not previously have for the pool account based on giving mimimum rights.
Please could you tell the best practice recommendations for the account of this service.
I changed the account of the aspnet state service from Network service to be the same as the domain account that is the identity of the app pool.
I noted the identity issue when I view the aspnet_state process during my testing, I apologize that I didn't tell you about this.
The aspnet_state process runs as Network service account. And web applicaton runs as the application pool identity, namely worker process identiy. Basically, when you create a web application with default application pool identity, there is none error arise.
But you mentioned you were used the domain account, I guess this is root cause why you access the aspnet_state process fails.
JamesC
I don't know if this is the best solution
You said you changed the account of the aspnet_state service, I suggest you to keep the default account(Network service) of aspnet_state process.
You can configure your domain account to have general privilege to access aspet_state process.
Please mark the replies as answers if they help or unmark if not.
Feedback to us
The Network Service account has the minimum privilege on the local computer. NETWORKSERVICE is a built-in Windows identity. It doesn't require a password and has only user privileges; that is, it is relatively low-privileged. When creating a web application
pool, the default application pool identity has the privilege accessing the aspnet_state process(I tested). I don't kown whether your domain account has the privilege to access it. But if you add your domain account into the administrators, the privilege problem
should be solved. This may have a risk for your computer. So the alternative, you can try to add your domain account into the IIS_IUSRS group. Why to add the domain account into the IIS_User group? IIS-IUSRS is a built-in identity group that is a container
of all worker process identities (WPIs) on the server. IIS automatically includes all WPIs in this group (no need to add them manually). The key is that the IIS-IUSRS can access the aspnet_state process(by default), so you can try adding your domain account
intot this group.
Please mark the replies as answers if they help or unmark if not.
Feedback to us
JamesC
8 Posts
Recycle app pool clears session even with state server
Apr 17, 2012 02:38 PM|LINK
Hi,
We have an application where we are changing from in proc session to state server. We recoded the necessary serialisation and enabled the state server process. When we run the app and take pages we can see the state server memory usage grow as session data is created. App works fine.
Problem is that when we recycle the pool, session data is lost (same as if it was using in-process) This happens on our test and production servers (2008R2) and also on a Win7 VS2010 devenv local iis. However we have another VS2010 in a contractor where the session is retained through the recycle, like it should be.
After many hours playing spot the difference between the two machines we can not find any ideas about what may be the difference that causes the problem.
The differences we know between the two environments are few. One is in AD domain and the (working one) is not. Pool identity is AD account in non working but local machine account in working. In non working sql is remote, in other it is local. We have switched web.config files between the environments, but to no avail.
I was hoping if someone has a check list of reasons why session could be lost during a recycle, as this is not expected behaviour.
Regards, James.
Mamba Dai - ...
651 Posts
Microsoft
Re: Recycle app pool clears session even with state server
Apr 19, 2012 07:32 AM|LINK
Hi,
When you set the sessionstate to stateserver mode, session should be maintained out of worker process, namely stored into aspnet_state process. If you recycle the application pool/worker process, the Session should not be lost. I test this session mode, all work fine like it should be. For you odd issue, it's difficult to locate what causes lead to session losing. Because the session is saved into aspnet_state process, you may confirm whether this process is disturbed/broken when you recycle the application pool.
Seem all your configuration is no problem. Now I suggest you to create another simple web site using stateserver mode to test again. If it works fine, that proves the web site occured session losing has some error configuration. To configure SessionState correctly please check this reference:
http://msdn.microsoft.com/en-us/library/h6bb9cz9.aspx
Feedback to us
Develop and promote your apps in Windows Store
JamesC
8 Posts
Re: Recycle app pool clears session even with state server
Apr 19, 2012 02:28 PM|LINK
Hi,
I did not find the answer to this yet. I tested by changing session state to sql. This worked as expected, we could see the sql data going in and out and could recycle the app pool without any problems for an open client.
Can you advise what we can do to "confirm whether this process is disturbed/broken when you recycle the application pool".
Thanks, J.
Mamba Dai - ...
651 Posts
Microsoft
Re: Recycle app pool clears session even with state server
Apr 20, 2012 03:13 AM|LINK
I mean you need to confirm whether the aspnet_state process works fine. For me, I create a simplest sample site to test stateserver mode of sessionstate, just a default page and web.config file, default page sets/gets the session. When I set the sessin and then recycle the application pool, I can retrieve the session set previously. As I suggest you before, try to create another simple site test again:
<system.web>
<sessionState mode="StateServer" stateConnectionString="tcpip=127.0.0.1:42424">
</sessionState>
<compilation debug="false" targetFramework="4.0" />
</system.web>
Feedback to us
Develop and promote your apps in Windows Store
JamesC
8 Posts
Re: Recycle app pool clears session even with state server
Apr 20, 2012 07:59 AM|LINK
I think I have found the problem. The recycle started working correctly when I changed the account of the aspnet state service from Network service to be the same as the domain account that is the identity of the app pool.
I don't know if this is the best solution. When I added this account is automatically added the right of Logon as a service, which we did not previously have for the pool account based on giving mimimum rights.
Please could you tell the best practice recommendations for the account of this service.
Thanks!
Mamba Dai - ...
651 Posts
Microsoft
Re: Recycle app pool clears session even with state server
Apr 20, 2012 09:01 AM|LINK
Hi,
I noted the identity issue when I view the aspnet_state process during my testing, I apologize that I didn't tell you about this.
The aspnet_state process runs as Network service account. And web applicaton runs as the application pool identity, namely worker process identiy. Basically, when you create a web application with default application pool identity, there is none error arise. But you mentioned you were used the domain account, I guess this is root cause why you access the aspnet_state process fails.
You said you changed the account of the aspnet_state service, I suggest you to keep the default account(Network service) of aspnet_state process.
You can configure your domain account to have general privilege to access aspet_state process.
Feedback to us
Develop and promote your apps in Windows Store
JamesC
8 Posts
Re: Recycle app pool clears session even with state server
Apr 20, 2012 09:36 AM|LINK
Could you give instructions how to do this?
Mamba Dai - ...
651 Posts
Microsoft
Re: Recycle app pool clears session even with state server
Apr 22, 2012 06:52 PM|LINK
The Network Service account has the minimum privilege on the local computer. NETWORKSERVICE is a built-in Windows identity. It doesn't require a password and has only user privileges; that is, it is relatively low-privileged. When creating a web application pool, the default application pool identity has the privilege accessing the aspnet_state process(I tested). I don't kown whether your domain account has the privilege to access it. But if you add your domain account into the administrators, the privilege problem should be solved. This may have a risk for your computer. So the alternative, you can try to add your domain account into the IIS_IUSRS group. Why to add the domain account into the IIS_User group? IIS-IUSRS is a built-in identity group that is a container of all worker process identities (WPIs) on the server. IIS automatically includes all WPIs in this group (no need to add them manually). The key is that the IIS-IUSRS can access the aspnet_state process(by default), so you can try adding your domain account intot this group.
Feedback to us
Develop and promote your apps in Windows Store