开发者

ASP.NET MVC View not returned in prod environment

开发者 https://www.devze.com 2023-03-11 02:36 出处:网络
I have a strange problem and I\'m looking for some debug pointers. When a page has been removed from a site I do the following:

I have a strange problem and I'm looking for some debug pointers. When a page has been removed from a site I do the following:

Response.StatusCode = 410;
Response.Status = "410 Gone";
return View("PageRemoved");

In the dev environment it works fine. In prod, the browser simply prints: "The page you requested was removed." but the View is not rendered. The 410 status is returned in both environments. At one point this was working in pr开发者_开发问答od but I don't know when.

Is it possible that IIS is intercepting the 410 return code and printing this message? If so, where in IIS would this have been setup? How would you debug this? (I've put log statements in the code and the code path is identical in both environments.)


It is possible that IIS is intercepting error responses and serving a custom page. You can set a custom error page for 410 errors in IIS that will execute a specified URL on your site (or a static page if you'd like). You can find this option in Your Site > Error Pages > Add.

You can also try the following in your controller action before returning the result:

Response.TrySkipIisCustomErrors = true;
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号