ASP.NET MVC: How to serve content while returning status code 404? [duplicate]

拈花ヽ惹草 提交于 2019-12-03 04:53:45
Marek

Setting

 Response.TrySkipIisCustomErrors = true; 

did the trick.

You are already doing the correct thing. You can look at Fiddler to confirm this.

However, there is no guarantee that a browser will honor your content. Wikipedia notes:

Internet Explorer (before Internet Explorer 7), however, will not display custom pages unless they are larger than 512 bytes, opting to instead display a "friendly" error page. Google Chrome includes similar functionality, where the 404 is replaced with alternative suggestions generated by Google algorithms, if the page is under 512 bytes in size.

Some trial and error and massaging of your view may be necessary in order to come up with a page which various browsers will actually elect to display.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!