使用mvc5中的所有http谓词处理自定义错误

时间:2017-10-04 04:42:08

标签: .net asp.net-mvc custom-errors

您好我正在开发mvc5中的Web应用程序。我使用自定义错误处理错误,我在web.config中的代码片段如下:

  <customErrors defaultRedirect="~/Login/Error/" mode="On" >
  </customErrors>

我有控制器登录和操作方法错误

  public ActionResult Error()
  {
    return View();
  }

以下是隐藏iis版本的代码。

  <customHeaders>  
  <remove name="X-Powered-By" /> 
  </customHeaders>

它按预期工作。 当我尝试在我的httprequester中使用PUT动词(这不存在)访问URL http://localhost:62777/dashboardtest时,我会获得iis版本。 附上的屏幕截图如下。

IIS version with PUT method

如果我使用GET方法命中相同的网址,则iis版本不可见。 屏幕截图如下。

IIS version with GET method

我想知道如何用所有http动词隐藏iis版本?任何帮助将不胜感激。谢谢。

0 个答案:

没有答案