I am using routing with my ASP.NET WebForms application, using the technique described by Phil Haack:
This works well most of the time, however on on occasion the first call to System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath
is takes tens of seconds to return.
This happens in the following method:
public IHttpHandler GetHttpHandler(RequestContext requestContext)
{
LapTimer lapTimer = new LapTimer();
string virtualPath = this.GetSubstitutedVirtualPath(requestContext, lapTimer);
if (this.CheckPhysicalUrlAccess && !UrlAuthorizationModule.CheckUrlAccessForPrincipal(virtualPath, requestContext.HttpContext.User, requestContext.HttpContext.Request.HttpMethod))
throw new SecurityException();
IHttpHandler page = BuildManager.CreateInstanceFromVirtualPath(virtualPath, typeof(Page)) as IHttpHandler;
if (page != null)
{
//Pages that don't implement IRoutablePage won't have the RequestContext
//available to them. Can't generate outgoing routing URLs without that context.
var routablePage = page as IRoutablePage;
if (routablePage != null)
routablePage.RequestContext = requestContext;
}
return page;
}
At the same time as this I notice (using Task Manager) that a process called csc.exe, the C# compiler, is taking up 10%-50% of my CPU.
Can anyone suggest why this would be happening?