0

I write custom error pages for my MVC 5 web app. That's why I extended my web.config:

<customErrors mode="On" defaultRedirect="~/Error/" >
  <error redirect="~/Error/?code=404" statusCode="404" />
</customErrors>

My Index action is called properly but I want to know the called url that was not found. How can I get it?

Koopakiller
  • 2,838
  • 3
  • 32
  • 47
  • it should be in the query string – Simon Halsey Aug 09 '15 at 23:36
  • @SimonHalsey the `Request.QueryString` property contains only the query for the error page: `{code=404}` – Koopakiller Aug 09 '15 at 23:52
  • @SimonHalsey The `Request.Url` property contains the path to my custom error page path: "https://localhost:44300/Error/?code=404" – Koopakiller Aug 09 '15 at 23:54
  • HTTP is stateless. IIS is capturing the 404 and redirecting you. You'll need to go about this in a different way. See [How can I properly handle 404 in ASP.NET MVC?](http://stackoverflow.com/a/9026941/1944400) – Rowan Freeman Aug 10 '15 at 00:08

0 Answers0