3

I have project at asp.net mvc. And there is problem i dont know how to solve: I add at web.config error handling, and that is ok, but it's return

HTTP/1.1 302 Found
Content-Length: 157
Location: /Error404.html?aspxerrorpath=/fghdhdfghg

which is wrong, i need HTTP/1.1 404 Not Found. I have tested at

that site

Do you know how to set error code for my error404.html page? I have tryed both Hardcoded html page & MVC Action.

2
  • Have you tried disabling custom error handling? Commented Dec 20, 2012 at 18:18
  • but i need custom design for that page Commented Dec 20, 2012 at 19:11

3 Answers 3

2

You can set Response.StatusCode = 404 or you can return a HttpNotFoundResult from the controller.

Sign up to request clarification or add additional context in comments.

3 Comments

Does that method allow to use custom design for that page? i got at tester HTTP/1.1 404 Not Found, but that has default asp.net design link
yes if you set the StatusCode in your controller before returning the view:
thancks. but it should be also setted Response.TrySkipIisCustomErrors = true; Works now.
0

You're getting the 302 (object moved) because you explicitly requested this in your configuration by telling it to use the alternate page in the case of a 404 error. Your other choice would be to let the web server send back the 404 error, but you wouldn't have the opportunity to send html content along with it (your whole reason for the redirect, presumably).

Comments

0

302 is not an error. It is the HTTP status code for "moved temporarily," which tells the Web browser / search engine that it should continue using the URL it used in the first place.

A 302 redirect is common when using mod_rewrite, PHP's header() and other such URL-changing schemes. is the caching enabled in your web server..???

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.