public static HandlerMethods GetHandlerMethods(HttpContext context, string requestPath)
{
string path = VirtualPathUtility.ToAbsolute(requestPath);
string cacheKey = HandlerMethods.CACHE_PREFIX + path;
HandlerMethods handlerMethods = null;
if (!IsDebugging)
{
handlerMethods = context.Cache[cacheKey] as HandlerMethods;
}
if (handlerMethods == null)
{
try
{
Type requestedType = BuildManager.GetCompiledType(path);
if (requestedType == null)
{
requestedType = BuildManager.CreateInstanceFromVirtualPath(path, typeof(System.Web.UI.Page)).GetType();
}
handlerMethods = new HandlerMethods(requestedType);
if (!IsDebugging)
{
PutToCache(path, context, cacheKey, handlerMethods);
}
}
catch (System.Web.HttpException e)
{
if (!requestPath.EndsWith(".aspx", true, CultureInfo.InvariantCulture))
{
return HandlerMethods.GetHandlerMethods(context, requestPath + "default.aspx");
}
throw e;
}
}
return handlerMethods;
}