title: asp.net mvc on azure - trouble with customErrors
body: <p>I've been banging my head against this for a few days without getting anywhere. I want to have a catch all error handler that redirects to a controller which displays a neat page to the user as well as do relevant logging and such. </p>
  
  <p>The thing is that everything works just fine locally, but when I upload to azure I get the standard error pages instead.</p>
  
  <p>It seems like azure does not execute the redirect, and ignores the global handler in global.asax as well.</p>
  
  <p>I did not include the code for the error controller here as it seems I never get that far.</p>
  
  <p>Web.Config:</p>
  
  <p><code>&lt;customErrors mode="On" defaultRedirect="/error" redirectMode="ResponseRewrite"&gt;&lt;/customErrors&gt;</code></p>
  
  <p>Route entry:</p>
  
  <p><code>routes.MapRoute("Error", "error/{*fluff}", new { controller = "Error", action = "Index", exception = new HttpException(404,"Direct call to controller") });</code></p>
  
  <p>From global.asax:</p>
  
  <pre><code>protected void Application_Error(object sender, EventArgs e)
  {
      var routeData = new RouteData();
  
      routeData.Values["controller"] = "Error";
      routeData.Values["action"] = "index";
      routeData.Values["exception"] = Server.GetLastError();
  
      Response.Clear();
      Server.ClearError();
  
      IController controller = new ErrorController();
      controller.Execute(new RequestContext(new HttpContextWrapper(((MvcApplication)sender).Context), routeData));
  }
  </code></pre>