我有一个 msdeployed 站点,它将包含一个指向单独内容文件夹的虚拟目录。当我托管非预编译时(即我的 IIS 托管网站指向我在 Visual Studio 中的项目目录)。
在我的本地机器上,我可以重定向到虚拟目录中的 html 页面,并且 html 页面正确显示。但是,当我将项目部署到我们的登台服务器时,我收到以下错误:
The file '/MedrioWeb/help/info/default.html' has not been pre-compiled, and cannot be requested.
at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate)
at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate)
at System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean throwIfNotFound)
at System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp)
at System.Web.UI.PageHandlerFactory.GetHandlerHelper(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath)
at System.Web.UI.PageHandlerFactory.GetHandler(HttpContext context, String requestType, String virtualPath, String path)
at System.Web.HttpApplication.MaterializeHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
在 IIS 中预编译的主要 Web 应用程序中,我将以下扩展添加到了 compiler\buildProviders:
<!-- forcing authentication for html pages -->
<add extension=".html" type="System.Web.Compilation.PageBuildProvider" />
<add extension=".htm" type="System.Web.Compilation.PageBuildProvider" />
接下来,我在 web 应用程序下的虚拟目录中有一个 web.config:
<?xml version="1.0"?>
<configuration>
<system.web>
</system.web>
<system.webServer>
<handlers>
<add name="HTML" path="*.html" verb="GET, HEAD, POST, DEBUG" type="System.Web.UI.PageHandlerFactory" resourceType="Unspecified" requireAccess="Script" />
<add name="HTM" path="*.htm" verb="GET, HEAD, POST, DEBUG" type="System.Web.UI.PageHandlerFactory" resourceType="Unspecified" requireAccess="Script" />
</handlers>
</system.webServer>
</configuration>
TL;DR:我收到非 asp.net 文件类型的预编译错误。我只包含扩展名,以便我的自定义表单身份验证模块用于验证用户是否已登录查看 html 页面。为什么这不适用于预编译代码,而不是我本地机器上的非预编译版本?