none
Problem mit customErrors RRS feed

  • Frage

  • Hallo NG,

    in meiner Web.config habe ich stehen:

    <customErrors mode="On"/>

    In der Global.cs:

     protected void Application_Error()
            {
                try
                {
                    var exception = Server.GetLastError();
                    var httpException = exception as HttpException;
                  
                    Response.Clear();
                    Server.ClearError();
                    var routeData = new RouteData();
                    routeData.Values["controller"] = "Error";
                    routeData.Values["action"] = "General";
                    routeData.Values["exception"] = exception;
                    if (exception is LockingException)
                        routeData.Values["action"] = "LockingException";
                    else
                    {
                        if (httpException != null)
                        {
                            Response.StatusCode = httpException.GetHttpCode();

                            switch (Response.StatusCode)
                            {
                                case 400:
                                    log.Error("400", exception);
                                    break;
                                case 403:
                                    routeData.Values["action"] = "Http403";
                                    log.Error("403", exception);
                                    break;
                                case 404:
                                    log.Error("404", exception);
                                    routeData.Values["action"] = "Http404";
                                    break;
                                default:
                                    log.Error(Response.StatusCode.ToString(), exception);
                                    break;
                            }
                        }
                        else
                            log.Error("Exception", exception);
                    }
                   
                    log.Debug("Url: " + Request.Url);
                    IController errorsController = new ErrorController();
                    var rc = new RequestContext(new HttpContextWrapper(Context), routeData);
                    errorsController.Execute(rc);
                }
                catch (Exception ex)
                {
                    log.Fatal("failed to display error page, fallback to HTML error: ", ex);
                }
            }

    Wenn ich einen 404 error produziere wird im IIS Express alles richtig angezeigt. Auf dem Produktiv Server IIS 7 wird die Standard 404 Seite angezeigt.

    Kann mir jemand eine Tipp geben was ich falsch mache??Danke für jeden Hinweis und Tipp im voraus.

    Grüße Ingo

    Freitag, 27. April 2012 11:26