Last post Dec 02, 2011 04:05 AM by Mamba Dai - MSFT
Nov 27, 2011 10:15 AM|cloucas|LINK
I have been trying to use application state (both using Application["key"] and HttpRuntime.cache to maintain state across an ASP.Net 4 application; while the methods work perfectly on my dev machine, when I deploy the files on the server the state items
disappear; I have seen a similar post here, with a relevant solution suggesting to ensure that the application's application pool is not using many worker threads, but by going to the IIS manager and viewing the pools advanced settings i see that the max number
of working processes is set to 1.
Any ideas of what can possibly be going on? I need this quite urgently, so I would appreciate a quick reply;
I am explaining a bit more below:
I have been developing an ASP.Net 4.0 web application, and I have used the HttpApplicationState class with its Contents property to set some variables in the Application_Start event of the Global_asax file.
While the application runs as expected on my development machine, when it is deployed on the production server running IIS7 the values returned for the application state variables are null. I have tried various code techniques, like using the HttpContext,Runtime.Cache,
the Application["key"], and the Application.Contents.Add["key",Value], all with no success. I am wondering now whether there should be a special configuration on IIS7 on this; researching the topic I see that people say that the application pool in which the
application is executed must be served by only a single worker process; I am no IIS7 expert, but selecting the application pool, and viewing its advanced properties, I can see that the pool is configured to have a maximum of 1 worker process, so I believe
this should cover it. I have spent a good 2 days on this, so if anyone has any knowledge of this issue, please help!
Nov 27, 2011 11:33 PM|cloucas|LINK
Just as an update; looking around on the Net it appears that application pools running in Integrated mode do not work whereas classic mode do; the only issue was that the classic mode pools did not serve the pages correctly (i.e. the pages appeared with
no css information). Since I am on a tight schedule, I abandoned the application state and went for session state instead (my tables stored in each session are small (about 30 rows each with about 8 columns and there are three such tables).
I still am interested if somebody offers some explanation and possible workaround of this problem, as it is indeed wasteful to store the same static data in each user session object; it would be very helpful if the application state actually works for asp.net
4.0 apps running in application pools in integrated mode.
Nov 29, 2011 05:06 AM|Mamba Dai - MSFT|LINK
I guess your Application state losts, because application state is stored in server memory, it is lost whenever the application is stopped or restarted. For example, if the Web.config file is changed, the application is restarted and all application state
And this post discussed one problem involved losting Application state:
Nov 29, 2011 12:33 PM|cloucas|LINK
thanks for your reply; ths issue is that the state is not lost after a while; the state is not loaded to begin with (i.e. the application does not work from the outset).I was expecting the application cache to be loaded on Application_Start event, however
it does not. After researching a bot I found a few references on here suggesting an issue with the application pool mode used in running the application under IIS. I switched the mode from Integrated to Classic, and the state worked. However running the app
under classic application pool is not an option as some features, like CSS do not work under classic mode (don't know why this is so).
Dec 02, 2011 04:05 AM|Mamba Dai - MSFT|LINK
the application pool mode used in running the application under IIS. I switched the mode from Integrated to Classic, and the state worked.
It indicates your issue is related to IIS, I suggest you to post a new thread to IIS fourm:
You will receive more professional and exact idea for your problem.