美文网首页.NET
webConfig 自定义404错误页面注意点

webConfig 自定义404错误页面注意点

作者: 念旧的时光 | 来源:发表于2018-12-24 22:29 被阅读0次

<system.webServer>

  <httpErrors errorMode="Custom" existingResponse="Replace">

      <remove statusCode="404" subStatusCode="-1" />

      <error statusCode="404" prefixLanguageFilePath="/404.html" path="/404.html" responseMode="ExecuteURL" />

    </httpErrors>

</system.webServer>

/*************************************************************************************************************/

备注:想要实现错误页面跳转404,但是Url保持用户输入错误链接,想要注意以下情况:customErrors 属性不能同时存在否则只会执行customErrors属性 而httpErrors不执行

/*************************************************************************************************************/

<system.web>

<customErrors mode="On" defaultRedirect="404.html">

    </customErrors>

</system.web>

相关文章

网友评论

    本文标题:webConfig 自定义404错误页面注意点

    本文链接:https://www.haomeiwen.com/subject/dsbtlqtx.html