Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you inspect the response using fiddler, I believe you'll find that the blank page is in fact returning a 404 status code. The problem is no view is being rendered and thus the blank page.</p> <p>You could get an actual view to be displayed instead by adding a customErrors element to your web.config that will redirect the user to a specific url when a certain status code occurs which you can then handle as you would with any url. Here's a walk-through below:</p> <p>First throw the <a href="http://msdn.microsoft.com/en-us/library/system.web.httpexception.aspx">HttpException</a> where applicable. When instantiating the exception, be sure to use one of the overloads which takes a http status code as a parameter like below.</p> <pre><code>throw new HttpException(404, "NotFound"); </code></pre> <p>Then add an custom error handler in your web.config file so that you could determine what view should be rendered when the above exception occurs. Here's an example below:</p> <pre><code>&lt;configuration&gt; &lt;system.web&gt; &lt;customErrors mode="On"&gt; &lt;error statusCode="404" redirect="~/404"/&gt; &lt;/customErrors&gt; &lt;/system.web&gt; &lt;/configuration&gt; </code></pre> <p>Now add a route entry in your Global.asax that'll handle the url "404" which will pass the request to a controller's action that'll display the View for your 404 page.</p> <p>Global.asax</p> <pre><code>routes.MapRoute( "404", "404", new { controller = "Commons", action = "HttpStatus404" } ); </code></pre> <p>CommonsController</p> <pre><code>public ActionResult HttpStatus404() { return View(); } </code></pre> <p>All that's left is to add a view for the above action.</p> <p>One caveat with the above method: according to the book "Pro ASP.NET 4 in C# 2010" (Apress) the use of <a href="http://msdn.microsoft.com/en-us/library/h0hfz6fc.aspx">customErrors</a> is outdated if you're using IIS 7. Instead you should use the <a href="http://www.iis.net/ConfigReference/system.webServer/httpErrors">httpErrors</a> section. Here's a quote from the book:</p> <blockquote> <p>But although this setting still works with Visual Studio’s built-in test web server, it’s effectively been replaced by the <code>&lt;httpErrors&gt;</code> section in IIS 7.x.</p> </blockquote>
    singulars
    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. 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.
    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