asp.net application takes long to start--even after compiling - asp.net

I have an asp.net app on IIS 7. It is 'pre-compiled', but I understand that IIS must still compile the assemblies the first time they're run.
Here is the problem--After I publish and deploy the application, I log in, and (as expected) it takes about 30 seconds to see the login page. Then I visit every page so that they are compiled (I have used the 'individual file for each page' or whatever option).
So far so good.
Then 10 minutes later i log in and it's near instantaneous. Still good and expected.
Yet the next day, my first logon takes 30 seconds or more again. Nobody changed web.config or copied any new assemblies in the meantime--this I am sure of.
Does anyone have an idea why this is happening? Is there an application timeout (as opposed to a session timeout)? Is there some setting in IIS admin console that I may have left at some default that is not optimal?
Thanks for any help on this,
James

Yes, starting an ASP.NET application in IIS is relatively slow. How much? It depends...
It's slow again the next day because IIS shuts down apps when they are inactive for some time.
The solution is "Application Initialization". This is built-in in IIS 8 and available out-of-band as a module for IIS 7.5:
http://www.iis.net/learn/get-started/whats-new-in-iis-8/iis-80-application-initialization

There is an Idle Time-Out on the Application Pool under Advanced Settings. Set this to 0 and the application will not stop due to inactivity.

Related

Why session get expired

We have an application (ASP Dot Net , Framework 4.0) in production which is deployed on IIS 7.5 window server 2012. Every day this application gets around 4000 requests, but the problem we are facing for the last couple of days is that some of the users complain their session gets expired. We have checked the application and don't see any error that can get the session expired. We've checked the IIS setting and pool setting, but we don't see any reason fair enough to sort out the issue.
Please help us in this regard to get this sorted out.
Probably I need to give more detail that helps you resolve my issue.
We work in professional organisation where we run many application on IIS for our clients. The issue we receiving is coming on one of the same application we build for our new client and deployed on IIS 8.0 server 2012.
In web config of our application time out is for one hour and further we make sure that we shouldn't route the user to session expire page if any other error comes. Now after making these changes we are pretty sure that issue should not be due to application configuration or due to the structure of it.
Now we are concern about the IIS. The different thing this time is we are using IIS 8.0 not IIS 7.5 which we are using on our all different servers for different applications.
Some of the IIS configuration you might be interested
we have dedicated pool for the application further pool is configured 2.0 because application is on the framework 3.5.
maximum worker process = 1
Pool recycle in 28 hours
Let me know if you could guide me anything specifically if that is related to IIS 8.0 because we are thinking of reverting back to 7.5, its our production application and clients are keep complaining about it.
The Life time of a session of a user is set by the developer / yourself. So you have privilege to set the time a user session time out at the desired time. Here is the format of th declaration in the web.config.
<sessionState mode="Off|InProc|StateServer|SQLServer"
cookieless="true|false"
timeout="number of minutes"
stateConnectionString="tcpip=server:port"
sqlConnectionString="sql connection string"
stateNetworkTimeout="number of seconds"/>
You can set the creation of cookies to true or false
Decide / dictate where the session information needs to be stored(server, database..)
These are some of the links that can help.
MSDN
MSDN2
I guess, you might have allocated the default application pool for this application in the IIS and the same application pool might have been shared among other applications too.
Step1: You should allocate separate application pool for each site in the IIS.
Step2: in application pool --> advanced settings --> Change the maximum worker process count to 1
If the above solution is not working, better try the solution which is given in https://technet.microsoft.com/en-us/library/cc781036(WS.10).aspx
Hope this helps.

How long does it take for IIS to shut down after app_offline.htm is in place?

I have a deployment workflow for an ASP.NET web app which begins with puttin an app_offline.htm file to the directory of my web app. Despite that, I usually get this error:
The process cannot access the file ... because it is being used by
another process.
Indicating that the IIS process is still running despite the fact that the app_offline.htm file is in place. If I remote desktop to the server and do a manual iisreset or shut down IIS with its GUI (or just wait a few minutes after manually putting the app_offline.htm file there, then the workflow works correctly.
So, how long does it take for IIS to shut down after app_offline.htm is in place?
I don't know but I would like to know. So I ran some tests...
The effect is pretty much immediate, but it may take some time for the IIS app to actually shut down due to extra clean up code. Expect files to be locked for some time even after app_offline.htm is in effect.
The actual file system event information takes just a few milliseconds to propagate.
The default is (up to) 90 seconds. This is defined in the application pool settings that your web application is running under in IIS as "Shutdown Time Limit".
Process Model documentation at Microsoft

How often ASP.NET typically recycles its applications (AppDomains)

I initialize static state of my web applications in Applications_Start method (Global.asax). At that time I write a message to log. Suddenly I've realized that this method was called every 10 minutes.
Is it corrected behavior? I expected ASP.NET to keep its applications at least for several hours.
Your expectation is incorrect. This is set in the application pool setting in IIS configuration. I think the default is 20 minutes. This can be changed to 0 if the application pool should not be recycled.
This is not typical. Something is causing it to restart and it should not be doing so this frequently. Check out How to find out why an ASP.NET web application is being restarted question to see how you can log details on why it restarted.
Since you are writing out log files, maybe you are writing them to a location that is be monitored for recompilation, which will cause a appdomain restart. Check out the post What causes an application pool in IIS to recycle?
Check out this article on iis.net to see the default for recycleing. It is 29 hours, so unless this setting has been changed for you, something else is causing it, not the automatic recycle.

How long does IIS retain compiled ASP.NET in cache before needing to be recompiled?

I am testing a piece of software called PowershellASP which lets you run powershell scripts inside an ASP.NET page, which I am driving via IIS 7.
Basically, on my test page, the first time it loads it takes over 60 seconds, which I assume is because the ASP.net needs to compile? It is fast on subsequent loads, except it then goes back to requiring 60 seconds+ if I leave it for an hour or so and then try refreshing the page after an hour... Any insight on the likely culprit for this behaviour (i.e. its "slow" after I try to refresh the page after an hour or so)...
Is this the IIS cache expiring and thus needing to recompile the ASP.NET page I'm trying to load or am I barking up the wrong tree?
regards, ted.
EDITED:To increase the idle timeout of a iis application go to advanced settings of your application pool and change the idle timeout to 0. Default is 20 min. The IIS doesn't exactly compile your application it load it into a worker which can take some time based on your application and the iis settings. After some idle the iis automaticly unload your application to save resources, that is why it takes more time after a while. Ones the app is loaded it runs fast.

IIS Recycling too often

We run a .NET 1.1 application on W2k3 server. The app pool is configured to recycle at 512MB. However, a week ago it started to recycle every 2 minutes. Since we run a web farm, the anonymous user we run IIS with is a domain account.
About a week ago, that user account expired, and we have to re-enable it. Could that have caused any problems? Maybe that user lost some permissions, or was left out of the IIS_WPG group.
Any advice will be greatly appreciated.
Try finding out more info by Logging ASP.NET Application Shutdown Events
Look in the server's Event Log. That may hold the answer.
If after checking the logs and all the standard "App Pool Health" settings (the obvious), I would look for other processes that might be mucking around with your web.config file (check the timestamp on it), which of course causes the app to restart.
I was once at a customer site and we couldn't figure out why our app kept restarting (and dropping all session state, etc...) Turned out it was a broken "Auto-Encrypt All Web.Config Files" little script that they had scheduled to run every 5 minutes. Problem was it never properly detected that it successfully had encrypted the file, so it just kept rewriting every 5 minutes... sigh..

Resources