1

I hav asp.net mvc 3 application.

When user pass id of non existing object I return 404 view in this way:

Response.StatusCode = 404; return View("404"); 

Locally all works fine and I have my custom error page. But on production, I have standart asp.net 404 page. I try to set customErrors either to "on" or "off" - results is the same.

2 Answers 2

1
<system.webServer> ... <httpErrors errorMode="Custom" defaultResponseMode="ExecuteURL"> <remove statusCode="404" subStatusCode="-1" /> <error statusCode="404" prefixLanguageFilePath="" path="/errors/404" responseMode="ExecuteURL" /> </httpErrors> 

Also, there is a new way you can return 404 from an action method:

// Response.StatusCode = 404; // return View("404"); return HttpNotFound(); 
Sign up to request clarification or add additional context in comments.

Comments

0

Found solution here: Routing for custom ASP.NET MVC 404 Error page

Set another magic setting in web config under system.webServer section:

<httpErrors errorMode="Detailed" /> 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.