I have the following function:
private ViewResult HandleInvalid()
{
Response.StatusCode = (int)HttpStatusCode.NotFound;
return View("Invalid");
}
On development machine (Windows 7), everything works well. The “Invalid” view is returned, along with status code 404.
On the production machine (Windows Server 2008), code execution stopped at the Response.StatusCode line and a status code 403 is returned along with empty content.
This happens on both ASP.NET and ASP.NET MVC. Any idea what may cause this?
It’s been a while but, what you can do is throw an HttpException(404, “Invalid”)