I'm newbie to MVC, trying to create a custom error page and show when user is looking for resource which isn't available. Followed few articles and able to show an custom error page.
- https://stackoverflow.com/questions/717628/asp-net-mvc-404-error-handling?answertab=votes#tab-top
I have created an Error Controller with 'NotFound404()' action method and view is created with the same name 'NotFound404.cshtml'.
- public class ErrorController : Controller
- {
-
- public ActionResult NotFound404()
- {
- return View();
- }
- }
Web.config
- <system.web>
- <customErrors mode="On">
- <error statusCode="404" redirect="~/Error/NotFound404"/>
- customErrors>
- system.web>
When i try to access any unknown resource, i can see the notfound404.cshtml. But when i inspect url it shows as 'http://localhost:xyzw/Error/NotFound404?aspxerrorpath=/New'.
Why do i get such wierd url? and i'm not using any aspx pages but it shows aspx in url. HTTP status under F12-Developer tools- Network - shows 200 OK. which isn't correct. How to rectify this.
And when i tried to access any static html page instead of a new controller/ action-view
- <system.web>
- <customErrors mode="On">
- <error statusCode="404" redirect="~/Shared/NotFound.html"/>
- customErrors>
- system.web>
404 Error occurs
is this error because of looking up for wrong path.?
My application folder structure
How to fix these errors and please show a right way to configure these error handling strategies.
Thanks in advance.