title: HTTP Error 404.0 - Not Found in MVC 5
body: <p>My project in MVC 5.i wanted to handel <strong>404</strong>. i did it but problem is that </p>
  
  <p>When I access the view using the following URL, everything works fine and as expected:</p>
  
  <pre><code>http://localhost/Hotels/Index30701000000
  </code></pre>
  
  <p>But when I access the view using following URL, I get 404.0 error message (error shown below)</p>
  
  <pre><code>http://localhost/Hotels/Edit/09099999dfdfb                       
  http://localhost/Hotels/Edit/090/20130701000000
  </code></pre>
  
  <p><strong>Error: HTTP Error 404.0 - Not Found The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.</strong></p>
  
  <p>My code is</p>
  
  <p><strong>Controller</strong></p>
  
  <pre><code>public class ErrorController : Controller
  {
      // GET: Error
      public ActionResult Unauthorized()
      {
          Response.StatusCode = 404;
          Response.TrySkipIisCustomErrors = true;
          return View();
      }
  }
  </code></pre>
  
  <p><strong>RouteConfig</strong></p>
  
  <pre><code>    routes.MapRoute(
          name: "Unauthorized",
          url: "Unauthorized/{action}/{id}",
          defaults: new
          {
              controller = "Error",
              action = "Unauthorized",
              id = UrlParameter.Optional
          }
      );
  </code></pre>
  
  <p><strong>Global.asax</strong></p>
  
  <pre><code>    protected void Application_Error()
      {
          Exception exception = Server.GetLastError();
          HttpException httpException = exception as HttpException;
      }
  </code></pre>
  
  <p><strong>webconfig</strong></p>
  
  <pre><code>  &lt;system.web&gt;
      &lt;customErrors mode="On" defaultRedirect="Error"&gt;
        &lt;error statusCode="404" redirect="Unauthorized" /&gt;
      &lt;/customErrors&gt;
    &lt;/system.web&gt;
  </code></pre>
  
  <p><strong>View</strong>  //Unauthorized.cshtml</p>
  
  <pre><code>@model System.Web.Mvc.HandleErrorInfo
  @{
      ViewBag.Title = "Unauthorized";
  }
  &lt;h1&gt;Page Not Found!&lt;/h1&gt;
  </code></pre>
  
  <p><a href="http://www.devcurry.com/2012/06/aspnet-mvc-handling-exceptions-and-404.html">Reference Link</a></p>