asp.net - 允许在 ASP.NET 和 IIS7.5 中的路径中使用加号字符

标签 asp.net iis-7.5

我有一个 ASP.NET Web 窗体网站,它使用 .NET 4 路由来处理自定义 URL。

我们组织中的某人决定宣传带有加号的 URL(例如 www.domain.com/this+that),所以现在我不得不修改系统以识别此 URL 并路由它到正确的页面。

这是一个在 IIS7.5 上运行的 .NET 4.0 网站。

我已经研究了如何做到这一点,建议是将以下内容添加到我的 web.config 文件中,我已经这样做了。但我仍然收到 IIS 404 错误消息,而且它甚至没有转到我的自定义 404 错误页面。

<system.webServer>
  <security>
    <requestFiltering allowDoubleEscaping="true">
    </requestFiltering>
  </security>
</system.webServer>

知道为什么这不起作用吗?

最佳答案

我只能从个人经验出发,但请尝试以下其中之一:

MVC:

    [ActionName("this+that")]
    public ActionResult ThisThat()
    {
        return View("ThisThat");
    }

web.config 重定向:

<location path="this+that">
<system.webServer>
<httpRedirect enabled="true" destination="www.domain.com/this_that" httpResponseStatus="Permanent" />
</system.webServer>
</location>

更新: 为我而努力。确保 web.config 如下所示:

<configuration>
    <system.web>
        <compilation debug="true" targetFramework="4.0" />
    </system.web>
    <system.webServer>
        <security>
            <requestFiltering allowDoubleEscaping="true" />
        </security>
    </system.webServer>

Global.asax 应该如下所示:

    protected void RegisterRoutes(RouteCollection routes)
    {
        routes.MapPageRoute("Test", "This+That", "~/Test.aspx");

    }

关于asp.net - 允许在 ASP.NET 和 IIS7.5 中的路径中使用加号字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18625362/

相关文章:

javascript - jQuery Ajax 内存泄漏

c# - 如何在asp.net html页面中给出id并访问 anchor 标记?

javascript - asp 文本框控件上的必填字段验证和当前日期验证

asp.net - 更改代码隐藏中的 web.config 设置

c# - ASP.net 在每次页面加载时抛出错误(Base-64 字符数组的长度无效)

c# - 页面可以选择退出 IIS 7 压缩吗?

c# - 无法加载文件或程序集 {此处的程序集名称} 或其依赖项之一。访问被拒绝

asp.net - ServiceReference 一个自托管的 WCF 服务

asp.net - SignalR 协商 404

asp.net - 我的 IIS7 URL 重写规则不断消失