private static IHttpHandler GetCompiledPageInstance(VirtualPath virtualPath, string inputFile, HttpContext context) { IHttpHandler handler; if (context != null) { virtualPath = context.Request.FilePathObject.Combine(virtualPath); } object state = null; try { try { if (inputFile != null) { state = HostingEnvironment.AddVirtualPathToFileMapping(virtualPath, inputFile); } BuildResultCompiledType type = (BuildResultCompiledType)BuildManager.GetVPathBuildResult(context, virtualPath, false, true, true, true); handler = (IHttpHandler)HttpRuntime.CreatePublicInstance(type.ResultType); } finally { if (state != null) { HostingEnvironment.ClearVirtualPathToFileMapping(state); } } } catch { throw; } return(handler); }
private static IHttpHandler GetCompiledPageInstance(VirtualPath virtualPath, string inputFile, HttpContext context) { // This is a hacky API that only exists to support web service's // DefaultWsdlHelpGenerator.aspx, which doesn't live under the app root. // To make this work, we add an explicit mapping from the virtual path // to the stream of the passed in file // Make it relative to the current request if necessary if (context != null) { virtualPath = context.Request.FilePathObject.Combine(virtualPath); } object virtualPathToFileMappingState = null; try { try { // If there is a physical path, we need to connect the virtual path to it, so that // the build system will use the right input file for the virtual path. if (inputFile != null) { virtualPathToFileMappingState = HostingEnvironment.AddVirtualPathToFileMapping( virtualPath, inputFile); } BuildResultCompiledType result = (BuildResultCompiledType)BuildManager.GetVPathBuildResult( context, virtualPath, false /*noBuild*/, true /*allowCrossApp*/, true /*allowBuildInPrecompile*/); return((IHttpHandler)HttpRuntime.CreatePublicInstance(result.ResultType)); } finally { if (virtualPathToFileMappingState != null) { HostingEnvironment.ClearVirtualPathToFileMapping(virtualPathToFileMappingState); } } } catch { throw; } }