Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I specify customErrors in my web.config file as below;</p> <pre><code> &lt;customErrors defaultRedirect="/Error/GeneralError" mode="On"&gt; &lt;error statusCode="403" redirect="/Error/403" /&gt; &lt;error statusCode="404" redirect="/Error/404" /&gt; &lt;error statusCode="500" redirect="/Error/500" /&gt; &lt;/customErrors </code></pre> <p>I have a route in the Global.asax as below;</p> <pre><code> /// Error Pages /// routes.MapRoute( "Error", // Route name "Error/{errorCode}", // URL with parameters new { controller = "Page", action = "Error", errorCode= UrlParameter.Optional } ); </code></pre> <p>The corresponding ActionResult does the following, which returns the relevant custom error page.</p> <pre><code>// public ActionResult Error(string errorCode) { var viewModel = new PageViewModel(); int code = 0; int.TryParse(errorCode, out code); switch (code) { case 403: viewModel.HtmlTitleTag = GlobalFunctions.FormatTitleTag("403 Forbidden"); return View("403", viewModel); case 404: viewModel.HtmlTitleTag = GlobalFunctions.FormatTitleTag("404 Page Not Found"); return View("404", viewModel); case 500: viewModel.HtmlTitleTag = GlobalFunctions.FormatTitleTag("500 Internal Server Error"); return View("500", viewModel); default: viewModel.HtmlTitleTag = GlobalFunctions.FormatTitleTag("Embarrassing Error"); return View("GeneralError", viewModel); } } </code></pre> <p>This allows me to have many different custom error pages. It's maybe not the best or most elegant solution, but it certainly works for me.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload