How to remove error messages - IIS7

前端 未结 3 1752
囚心锁ツ
囚心锁ツ 2020-12-17 21:25

I\'m wondering how to remove the error messages IIS7 adds to the top of the page.

I have my own 500 and 404 error pages served.

Not needing the error pages I

相关标签:
3条回答
  • 2020-12-17 21:55

    To prevent IIS7 hijacking your error pages, set existingResponse="PassThrough" in your httpErrors section in your web.config file. For example:

    <configuration>
      <system.webServer>
        <httpErrors existingResponse="PassThrough" />
      </system.webServer>
    </configuration>
    
    0 讨论(0)
  • 2020-12-17 21:59

    You can also go into IIS manager --> Error Pages then click on the right on "Edit feature settings..." And set the option to "Detailed errors" then it will be your application that process the error and not IIS.

    0 讨论(0)
  • 2020-12-17 22:02

    Just for addtional information I'll share what helped me:

    <system.webServer>
      <httpErrors errorMode="DetailedLocalOnly">
    </system.webServer>
    

    In such setup I could see detailed errors when developing on my local machine, but they would not be shown to users when remote server is accessed from outside.

    You could find more information regarding errorMode here.

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