title: Asp net 404 page with parameters
body: <p>I'm developing new web site in asp net mvc 5. And I want to create custom 404 page where users who tried to access old url will be redirected. The problem is that I want to create view for this error page and take parameters from url  trying to identify what product users tried to access. But I haven't found solution how to create it. All examples with editing webconfig like this:</p>
  
  <pre><code> &lt;defaultRedirect="~/Errors/NotFound" mode="Off"&gt;
            &lt;error statusCode="404" redirect="~/Errors/NotFound" /&gt;      
    &lt;/customErrors&gt;
  </code></pre>
  
  <p>will not pass parameters. I tried to disable custom errors and make changes in Global.asax :</p>
  
  <pre><code>public void Application_Error(object sender, EventArgs e)
          {
  
              Exception exception = Server.GetLastError();
              Response.Clear();
  
              HttpException httpException = exception as HttpException;
              if (httpException != null)
              {
                  if(httpException.GetHttpCode() == 404)
                  {                    
                      var rd = new RouteData();
                      rd.Values["controller"] = "Errors";
                      rd.Values["action"] = "NotFound";
                      rd.Values.Add("queryString", HttpContext.Current.Request.Url.AbsolutePath);
  
                      IController c = new ErrorsController();
                      c.Execute(new RequestContext(new HttpContextWrapper(Context), rd));
                  }
  
              }
          }
  </code></pre>
  
  <p>But it still returns standart error page</p>
  
  <p><a href="https://i.stack.imgur.com/JD6ED.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JD6ED.jpg" alt="enter image description here"></a></p>