【问题标题】:IIS Displaying 404 page even customErrors set to onIIS 显示 404 页面甚至 customErrors 设置为 on
【发布时间】:2015-12-16 21:57:36
【问题描述】:

我在 web config 的 system.web 标签中添加了这些代码

<customErrors mode="On" defaultRedirect="Error/Index">
  <error statusCode="404"
       redirect="Error/Index/404" />
  <error statusCode="403"
   redirect="Error/Index/403" />
</customErrors>

当我输入 localhost/controllername/actioname 时,重定向正在工作

但是当我输入localhost/a/a/a/a/a/a/a/a

它显示一个 IIS 404 not found 页面。

还有其他设置吗?谢谢

【问题讨论】:

    标签: iis web-config


    【解决方案1】:
    <httpErrors errorMode="Custom" existingResponse="Replace">
      <remove statusCode="404"/>
      <error statusCode="404" responseMode="ExecuteURL" path="/Error/404"/>
    </httpErrors>
    

    http://benfoster.io/blog/aspnet-mvc-custom-error-pages

    MVC 5 HttpErrors + Controller/Action

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-07-16
      • 2016-04-16
      • 2016-03-09
      • 2014-10-02
      • 2016-06-28
      • 1970-01-01
      • 2020-04-30
      • 1970-01-01
      相关资源
      最近更新 更多