IIS 8 Publish - eliminate hang time when application gets updated - asp.net-mvc

What are the best practises to limit (or best, eliminate) hang time when publishing changes to a single-server IIS 8 ASP.NET MVC application?
Now, we are deploying our changes via MSBuild.exe trough TeamCity. Once the app is deployed, it hangs for a little less than a minute doing its startup things (building NHibernate proxy assemblies, changing db schema, building ioc container etc.).
Is there a way for us to setup that the "old" process keeps handling requests until the new one is fully ready (and not just deployed) ?
EDIT:
Our startup code is launched via the
[assembly: WebActivator.PreApplicationStartMethod(typeof(..), "..")]
attribute.

You didn't specify what version of IIS you are using, but if you are using version 8.0 then you might want to take a look at the Application Initialization feature: http://www.iis.net/learn/get-started/whats-new-in-iis-8/iis-80-application-initialization
You'll want to set your application pool start mode to AlwaysRunning and then set preloadEnabled to true. Setting preloadEnabled to true tells IIS 8.0 to send a "fake" request to your application when the associated application pool starts up, whilst this won't eliminate the startup compilation, it will mean your application is available sooner than it was previously. You can also set IIS to display an alternative page whilst compilation is occurring, if you don't want your users hanging on...

Related

Published mvc app loading forever

I've published an MVC application on IIS 7.5 on external server. But when i run it it just says "Waiting for..." and nothing is happening! No errors, no application logs (because the application didn't even started), no IIS logs, no errors/warnings in event viewer. Can you tell me what can I do to track what is going on? Keep in mind that in development environment everything works fine. Also I already published the same application on another server and it is working like a charm.
the best you can do is to add glimpse to your project and see its reports,
btw, if you are using a shared host it could be a memory limitation, slow CPU, slow bandwidth,....a lot of possibilities....

MVC and EF randomly cause exceptions

I have a web application running on a deployment server that uses MVC5 and EF6. I have the same version concurrently running on my development machine. I can make updates or add functionality and test it on the development machine and have no problems, then publish it to the deployment server and it will work fine.
From 2-8 days all of a sudden the system starts giving me entity validation errors, or giving me an error about changing an entities Id in a simple page that does nothing but load some entities and iterates through the list to display them.
To fix the problem I literally do nothing other than go back in to VS2013 and click publish...I don't change any code or settings...and it works again.
Anyone else have this problem or know what could be the cause? Its not a complex web app and there are no background processes running.

MVC3 Application in Azure Cloud Service seems to be recyling too often with long initial waits

I have a Windows Azure Cloud Service which is running:
MVC3, C#, EF4.1, Razor
on
Windows 2012 R2 with .NET4.5 in WACS(osFamily="4")
I am finding that if I leave the application for a little while, say 10-15 minutes, the initial duration of the process is very long, can be about 2 mins. I assume this is due to the assemblies dropping out of memory, and the IL code needing to be recompiled. I suspect this is also tied into the application pool recycling too often.
First off, is it possible to precompile my MVC3 application and then deploy to WACS so if the assembly is dropped/recycled then it will load again very quickly. If so, how? I may well have missed something very obvious.
I guess I can also alter the setting on the app pool within the WACS IIS manager?
Thanks in advance.
EDIT:
I have found : /p:PrecompileBeforePublish=true , but not sure how to use it in conjunction with the VS2012 Azure publish action.
Check http://blog.smarx.com/posts/controlling-application-pool-idle-timeouts-in-windows-azure for how to set the IIS idle timeout to never.
Essentially, you want to create a startup task that does:
%windir%\system32\inetsrv\appcmd set config -section:applicationPools -applicationPoolDefaults.processModel.idleTimeout:00:00:00

Should .NET MVC 3 actions trigger w3wp.exe to generate Process Monitor "PATH NOT FOUND" and "NAME NOT FOUND" errors?

If I create an out-of-the-box ASP.NET MVC 3 Web Application (non-empty, Razor, no unit tests) and deploy it to an IIS 7.5 site (.NET 4, Integrated Pipeline), every controller action I trigger causes a ton of "name not found" and "path not found" errors in procmon.
The w3wp.exe process is trying to visit file system locations that the MVC Routing engine should pick up and handle. This is a small portion of the procmon log after clicking the "LogOn" link one time only:
Is this expected behavior? It doesn't feel right to me.
I came across this because my server CPU utilization was pegged at 100%. One of my calls was happening frequently enough (causing the "path not found" error) that it was eating up CPU. As soon as I created a file system folder at the path it was trying to access, the CPU utilization dropped to 0% (~85 concurrent users on the site in both cases).
You're probably in the Debug configuration. When DEBUG is defined, MVC does a ton of file probing which it doesn't do in Release configuration (Release uses a file cache, so you only pay this cost the first time). As a general rule, you should always use Release configuration for performance testing.
10 years late... Have you tried setting allowSubDirConfig to false?
It's not necessarily right or wrong. Microsofts default is for the w3wp.exe worker to check those directories so you can have a different web.config than the root application (e.g. a child application). It seems like an ancient default, because if you're deploying Microsoft apis you almost always want the IIS worked to hand off routing to dotnet/dotnetcore immediately. I'm not an IIS admin though, so I probably have an incomplete understanding. We found we gained a slight performance increase with the configuration set to false.

Server application unavailable in a MVC2 application over IIS 6

I created an application pool, and i assigned to it a test application(simple 1 view that renders hello, one action and one controller ) that i made in MVC
The thing is that when i executes as many times as i want it works, but after some hours (i dont know why), if i enter again into my server and i execute it, crashes.
The thing is that the only user that executes this application is me. Im wondering the following:
Are in IIS 6 any default setting that says something like: "Pool, shutdown if there arent request during certain amount of time"?
Thanks in advance.
Best regards.
I found the problem.
In the application pool there wasn't only one application, there were two.
The first one, configured to run on asp.net 2.0, and the other (my test application configured to run on Asp.net 4.0). Every time I reset the pool and execute one application, the other crashes.
The solution: All the applications running on the same application pool should be configured to run in the same version of asp.net

Resources