我的帐户页面(登录,注册等)正在使用根目录的Site.Master。由于默认情况下禁用父路径(?),我收到以下着名错误:
无法使用前导..退出顶级目录。
我在stackoverflow上找到了一个非常有前途的解决方案,但对我来说没有用
以下是有关部分:
<system.webServer>
<serverRuntime />
<asp
enableParentPaths="true"
scriptErrorSentToBrowser="true">
<cache diskTemplateCacheDirectory="%TEMP%\iisexpress\ASP Compiled Templates" />
<limits />
</asp>
<caching enabled="true" enableKernelCache="true">
</caching>
<cgi />
<defaultDocument enabled="true">
<files>
<add value="Default.htm" />
...
...
...
你还有其他建议吗?我从谷歌搜索它几个小时,但无法找到任何有用的东西。实际上,如果我为帐户页面创建一个单独的母版页,那么我不会收到任何错误,因为它没有尝试进入上层目录,但我不需要任何其他母版页并认为那里应该是一个更合适的解决方案。
答案 0 :(得分:3)
我在 Visual Studio 2012 中遇到了同样的问题 - 这是我的解决方案:
<system.webServer>
<asp enableParentPaths="true" />
</system.webServer>
是必需的,但导致错误消息 HTTP / 1.1新应用程序失败。 我还必须将 C:\ Users \ [Username] \ Documents \ IISExpress \ config \ applicationhost.config 中的overrideModeDefault从拒绝更改为允许
<sectionGroup name="system.webServer">
<section name="asp" overrideModeDefault="Allow" />
...
这样做了: - )
答案 1 :(得分:0)
虽然它没有解决我的问题,但我只想分享正确添加enableParentPaths的正确方法。
我想以下部分,因为它没有被“location path ='网站名称'”包围,对整个asp.net项目都有效:
<system.webServer>
<serverRuntime />
<asp
enableParentPaths="true"
scriptErrorSentToBrowser="true">
<cache diskTemplateCacheDirectory="%TEMP%\iisexpress\ASP Compiled Templates" />
<limits />
</asp>
<caching enabled="true" enableKernelCache="true">
</caching>
<cgi />
<defaultDocument enabled="true">
<files>
<add value="Default.htm" />
...
...
...
如果只想为特定网站添加enableParentPaths或任何其他选项,我们必须在命令提示符下运行该代码:
appcmd.exe set config "Website Name" -section:system.webServer/asp /enableParentPaths:"False" /commit:apphost
由于我某处没有特定于我的项目的“location”部分,因此该命令在我的applicationhost.config末尾添加了以下部分。
</location>
<location path="Medical_BootStrap">
<system.webServer>
<asp appAllowClientDebug="true" appAllowDebugging="true" errorsToNTLog="true" enableParentPaths="true" scriptErrorSentToBrowser="true" bufferingOn="true">
<session allowSessionState="true" />
<cache diskTemplateCacheDirectory="%TEMP%\iisexpress\ASP Compiled Templates" />
<limits />
</asp>
</system.webServer>
</location>
我认为那些想要为正确的网站添加正确方式的人会很有用。
答案 2 :(得分:0)
我最近遇到过类似的问题,所以也许这可以帮到你。如果使用IIS Express的/path:
命令行选项,则会忽略applicationhost.config
中的设置。解决方案是创建一个新的WebSite部分,如下所示:
<site name="YourApplication" id="12345" serverAutoStart="true">
<application path="/" applicationPool="Clr2IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\Path\To\Your\Application" />
</application>
<bindings>
<binding protocol="http" bindingInformation=":8080:localhost" />
</bindings>
</site>
然后使用/site:YourApplication
命令行而不是/path:
运行IIS Express。