ASP.NET Custom 404 Returning 200 OK Instead of 404 Not Found

前端 未结 7 560
Happy的楠姐
Happy的楠姐 2020-11-30 23:32

After trying to setup my site for Google Webmaster Tools I found that my Custom ASP.NET 404 page was not returning the 404 status code. It displayed the correct custom page

相关标签:
7条回答
  • 2020-12-01 00:15

    The IIS 7 solution is to just add this to your web.config file:

    <system.webServer>
      <httpErrors existingResponse="Replace">
        <remove statusCode="500" subStatusCode="-1" />
        <remove statusCode="404" subStatusCode="-1" />
        <error statusCode="404" prefixLanguageFilePath="" path="404.htm" responseMode="File" />
        <error statusCode="500" prefixLanguageFilePath="" path="500.htm" responseMode="File" />
      </httpErrors>
    </system.webServer>
    

    http://forums.asp.net/t/1563128.aspx/1

    0 讨论(0)
提交回复
热议问题