【问题标题】:Custom route for specified errors in web.configweb.config 中指定错误的自定义路由
【发布时间】:2015-06-20 07:12:43
【问题描述】:

我的 web.config 中有这个自定义错误配置:

<customErrors 
  mode="On"
  defaultRedirect="/common/ErrorPage.html?webconfig">
</customErrors >

现在我需要为某些特殊页面重定向到不同的错误页面,但仍保持 "/common/ErrorPage.html?webconfig"&gt; 像默认值一样。这可能吗?

【问题讨论】:

    标签: asp.net web-config custom-errors


    【解决方案1】:

    如果您的特殊页面可以在特定的 ASP.NET MVC 区域中,一种方法是使用基于不同位置的自定义错误路径。 (来自this

    <system.web>
      <customErrors mode="On" defaultRedirect="error" />
    </system.web>
    .
    .
    .
    <location path="areaName">
      <system.web>
        <customErrors mode="On" defaultRedirect="/areaName/error" />
      </system.web>    
    </location>
    

    【讨论】:

    • 我在 ASP.NET 2.0 而不是 MVC 上开发
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-10
    • 2016-08-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多