We have IIS version 6.2 for running an ASP.net application.
We have a application pool for this web application.
The .net framework version is "4.0".
"Startmodus" is "AlwaysRunning".
Why is the first access of a user always slow?
I found several questions releated to this topic but I cannot see why "AlwaysRunning" is not helping here.
Is it a good idea to create a powershell script accesssing the web application every 15 minutes in order to avoid this "IIS sleep mode"?
a little late to the party, but it seems what you need is either set the Idle Time-out to zero (default is 20) means every 20 minutes the application pool will be restarted. Source
Also there is a tag in web.config, to tell iis to send a fake request to you app at start up , to make sure you app is completley initialized :
<applicationInitialization
remapManagedRequestsTo="Startup.htm"
skipManagedModules="true" >
<add initializationPage="/default.aspx" />
</applicationInitialization>
Source
I had to install the 'Application Initialization' feature of IIS (only IIS 8+ I think).
https://www.iis.net/configreference/system.webserver/applicationinitialization.
Furthermore I had to set following settings:
App pool: StartMode always running
The page: Preload enabled
And finally recycle the app pool for the changes to take effect.
AlwaysRunning means that it won't shut down if it's idle.
So, you need to configure Auto Start as well:
In IIS Manager, click computer name in the Connection pane.
Switch to Features View if the view is not active.
Double-click Configuration Editor in the Management section of the
Features View.
Click the down-arrow for the Section field, expand
system.applicationhost, and then click application pools.
Click (Collection) and then click eclipses (…) next to the field
that shows the count.
In the Collection Editor, select the application pool for which you
want to configure the startMode attribute.
In the Properties window at the bottom, set the value of autoStart
attribute to True.
Complete info here
Related
What I want is that my Application_Start in Global.asax (Or any other piece of code) runs automatically whenever application pool/Application restarts in IIS. Application_Start gets triggered on the first request but I don't want to wait for the first request, but I want to do something whenever my Web API is deployed and started.
So, Is there any way via code (Not at IIS Level) that can achieve the above?
I'm not absolutely sure but you can try set "Start Mode = Always Running" for your application pool.
Edit 1: This should enforce IIS to directly load/reload your application pool and thus triggering Application_Start of your Global.asax
Edit 2
Just to make it clear, this is what i meant.
Go to application pools
Right Click your application pool
Go to advanced settings
Change OnDemand to AlwaysRunning
Yes this is not code based. But as of I know you have to configure application pool to achieve what you want.
Maybe you want to check this too (contains samples for code based app pool configuration): Application Pool Defaults
Maybe the answer is trivial, but I couldn't find the exact same behavior in other threads.
I have an MVC 5 web application. I implemented custom identity database with Asp.Net Identity 2 (Owin). I have only external login (facebook, google...etc). The login works fine. The users got authenticated with roles and everything.
After one minute of inactivity, my Visual Studio 2013 debug session stops. Sometimes the application remains available (so IIS App Pool is not stopped) sometimes it recycles IIS as well.
I also implemented logging in Application_End Global.asax method in order to have the shutdown reason, but in these cases there is no info in the logs. In other cases, when the App pool is recycled due to web.config change I do have info in the logs.
I suspect timeout, however I have no clue what kind of timeout it could be. Where should I look?
Thanks in advance.
I ran into the same problem, and found out how to set the timeout for IIS Express:
On the command window, navigate to the folder where IIS Express is installed, and execute the following appcmd command:
c:\Program Files (x86)\IIS Express> appcmd set config /section:applicationPools /[name='Clr4IntegratedAppPool'].processModel.idleTimeout:0.00:00:00
(scroll right to see the whole line)
Open IIS, find your application's AppPool, then:
Right click on the app pool and select Advanced Settings
Under "Process Model" set Idle Time-Out (minutes) to 0.
For reference, the only non-default (non-bold) settings in my "Process Model" and "Recycling" section are:
Identity : NetworkService
Idle Time-out (minutes) : 0
Ping Enabled : False
And with these settings, I can start up the debugger and it never seems to automatically time out or recycle.
Daniel I have had this exact same issue for a few months now and was about to go crazy about it. But I stumbled on a suggestion to run visual studio as administrator and that seems to have worked.
I currently have a WiX installer which is used for deploying a web application into IIS.
The application makes use of Lucene.Net and it's near-real-time search features.
Unfortunately a side-effect of this is that the Lucene indexes are held open/locked for the duration of the application running. This means if "Disable Overlapped Recycle" is set to false, then when the application pool recycles (e.g. during an upgrade) then we hit issues with lucene indexes still being locked by the previous instance.
The work-around is to change the "Disable Overlapped Recycle" to True within the advanced settings of the application pool, but I can't figure out how to do this with wix.
Is there anyway I can automate setting this value via WiX?
FYI - Here's what the WebAppPool section looks like currently in my installer project:
<iis:WebAppPool Id="AppPool" Name="Some App" ManagedRuntimeVersion="v4.0"
IdleTimeout="0" RecycleMinutes="0" ManagedPipelineMode="integrated"
Identity="networkService" />
Occasionally you'll come across IIS metabase properties that aren't exposed by the custom actions provided by either WiX or InstallShield. In those cases it's usually easiest to call the AppCmd.exe using the Quiet Execute Custom Action.
Basically leverage the IIS extension to it's fullest and then tweak the app pool near the end of the install.
My website was down several times per day and when I check the application pool (IIS 7.5), I saw it was stopped and I must restart it manually. How can I setup application pool so that it automatically restarts after an error?
You will need to change the startMode for the application pool your website is running on from onDemand to AlwaysRunning. By default IIS sets all application pools to onDemand.
In IIS Manager, click computer name in the Connection pane.
Switch to Features View if the view is not active.
Double-click Configuration Editor in the Management section of the Features View.
Click the down-arrow for the Section field, expand system.applicationhost, and then click application pools.
Click (Collection) and then click ellipses (…) next to the field that shows the count.
In the Collection Editor, select the application pool for which you want to configure the startMode attribute.
In the Properties window at the bottom, set the value of startMode attribute to AlwaysRunning.
Source: http://msdn.microsoft.com/en-us/library/ee677285%28v=azure.10%29.aspx
In IIS 8 and above, the start mode setting is now directly available from the Application Pool's Advanced Settings.
In IIS 8 and above, the startMode setting is now directly available from the Application Pool's Advanced Settings.
Changing the startMode to AlwaysRunning will automatically restart the Application Pool if it fails.
https://learn.microsoft.com/en-us/iis/configuration/system.applicationhost/applicationpools/add/#new-in-iis-75-and-later
Problem with "By default IIS sets all application pools to onDemand" is when you have to update the bits. Then the site will restart and lock the deployment. Better to set the Rapid-fail protection under advanced settings under app pool. Set Failure interval (min) to 1, and Max fail to 5.
I have an ASP.NET website and when I press F5 it automatically attaches to the ASP.NET Development Server, how do I attach to IIS worker process instead when I press F5?
Debug->Attach To Process...
Select the aspnet_wp.exe process from the list.
If you're running IIS > version 5 the process will be w3wp.exe, and there will be one for every app pool (so if you don't know which app pool you're hitting, you'll need to attach to all of them).
open project properties, go to the web tab and choose the option for IIS.
That actually starts an instance of the app in IIS and attaches the debugger. If you only wanted to attach to an existing IIS instance, choose attach to process from the debug menu.
Debug -> Attach to Process from the VS menu.
In order to know to which w3wp.exe process to attach you can use the following command on a 2008 server
c:\%systemroot%\system32\inetsrv\appcmd list wp
While on windows 2003 it is
c:\%systemroot%\system32\cscript iisapp.vbs
For more info see IIS Application pool PID.
However if you have access to the task manager (taskmgr.exe) you can see there directly the name of the process along with the process ID, and in most cases the "user name" column of the process will be the same as the application pool name, (of course you have to set these columns to be visible in task manager in order to view the information).
But note that all of the methods will display only the processes that are currently running, which means that if your particular process has shut down due to idle time you have first to use the site in order to bring the process up in the list.
Also if the application is a "Web Garden" (which has more than one w3wp.exe) then even after attaching to the correct process there is still no guarantee that the breakpoints will be hit, since traffic to the site might be directed to another process.
Also note that if you attach to an application that runs in release mode, it will now instead run in debug mode, which means for example that there will be no timeout limitations (which might be a bit of a problem if you are actually trying to troubleshoot a timeout error).
If you want to attach to a remote process here is the best practice:
Make sure that the firewall is not blocking by opening the relevant ports or completely disabling it (just remember to turn it on again when done).
You should have a windows domain account with administrative privileges on the remote machine or have an account - with the same username and password as the local machine which is running VS - on the remote machine.
On the machine that has VS installed navigate to (Visual Studio Install path)\Microsoft Visual Studio (current version number)\Common7\IDE\Remote Debugger(Remote Machine Version), and copy and paste this folder to the remote machine or share this folder so that it is accessible from the remote machine.
On the remote machine log in as the same user as the local machine (see step 2) from there navigate to the copied or shared folder of step 3, and right click on "msvsmon.exe" and from the context menu select "Run As Administrator".
The Remote Monitor should start up and claim that it started a server usually by the name of (user)#(remote machine) or any other name.
In VS select Debug -> Attach To Process from the menu, leave the transport on "Default" and for the "Qualifier Name" enter the name from step 5.
If everything goes correctly this will bring up the list of processes on the remote machine.
Of course there is a lot more in this subject, and for debugging native code the process might be even simpler, but the steps I have listed here should work in every case.
For farther information you can take a look on http://www.codeproject.com/KB/aspnet/IISRemoteDebugging.aspx or on the MSDN, as well as many posts on this site.
Hope this will help.
Or you can use one of the Attach to IIS plugins to Visual Studio.
My preferred extension is VSCommands (for VS 2010 - 2012 or 2013, but not 2015 yet) or ReAttach (works in 2017).
go to the properties of the web application. Select the "Start Options" section, and change from "USe default web server" to "use custom server". Enter "http://localhost" in the base url.
(assumes VS 2008)