【问题标题】:IIS Express Enabling Parent PathsIIS Express 启用父路径
【发布时间】:2013-11-20 22:08:14
【问题描述】:

我的帐户页面(登录、注册等)正在使用根目录的 Site.Master。由于默认情况下禁用父路径(?)我收到以下著名错误:

不能使用前导 .. 退出顶级目录。

我在 stackoverflow 上找到了一个非常有前途的解决方案,但对我不起作用

iis-express-and-classic-asp

以下是相关部分:

<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" />

            ...
            ...
            ...

您还有其他建议吗?我从几个小时开始就在谷歌上搜索它,但找不到任何有用的东西。实际上,如果我为帐户页面创建单独的母版页,那么我不会收到任何错误,因为它不会尝试转到上层目录,但我不需要任何其他母版页,并且认为应该有更合适的解决方案.

【问题讨论】:

  • 我没有将 IIS Express 与经典 ASP 一起使用,但在常规 IIS 中,启用 ASP 父路径 (prashantd.wordpress.com/2010/06/22/…) 很容易。也许如果您可以使用常规 IIS,它可能会解决您的问题。
  • 是的,你甚至可以通过配置向导来实现,我猜,最坏的情况下,我会将站点带到正常的常规 IIS

标签: c# asp.net iis


【解决方案1】:

我在 Visual Studio 2012 中遇到了同样的问题 - 这是我的解决方案:

<system.webServer>
  <asp enableParentPaths="true" />
</system.webServer>

是必需的,但导致错误消息 HTTP/1.1 New Application Failed。 我还必须将 C:\Users\[Username]\Documents\IISExpress\config\applicationhost.config 中的 overrideModeDefault 从 Deny 更改为 Allow

<sectionGroup name="system.webServer">
  <section name="asp" overrideModeDefault="Allow" />
  ...

做到了:-)

【讨论】:

  • 如果有人像我第一次一样来到这里,This is a post 详细说明我必须为 Visual Studio 2015 做些什么。
【解决方案2】:

虽然它没有解决我的问题,但我只是想分享添加 enableParentPaths 的正确方法。

我猜下面这部分,因为它没有被“位置路径='网站名称'”包围,对整个 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

由于不知何故我的项目没有特定的“位置”部分,因此该命令在我的 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>

我认为这对于那些想要为必要的网站以正确方式添加它的人很有用。

【讨论】:

    【解决方案3】:

    我最近遇到了类似的问题,所以也许这可以帮助你。如果使用 IIS Express 的/path: 命令行选项,它会忽略applicationhost.config 中的设置。解决方案是创建一个新的网站部分,如下所示:

            <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。

    【讨论】:

      猜你喜欢
      • 2020-02-07
      • 1970-01-01
      • 2014-08-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-02-14
      相关资源
      最近更新 更多