How do I stop IIS7 from putting out its own 404 before my MVC app gets a chance to handle it?

后端 未结 5 1620
情书的邮戳
情书的邮戳 2021-01-01 23:19

I have an ASP.NET MVC 2 application, which has an Application_Error event handler in global.asax. In this, I\'m detecting the case where the Exception type is HttpException

5条回答
  •  情书的邮戳
    2021-01-01 23:58

    The Answer by Flynn solved my issue of ASP.NET taking control of the 404

    Now I am able to do this:

    Response.TrySkipIisCustomErrors = true;
    Response.StatusCode = 404;
    Response.Write("");
    HttpContext.Current.ApplicationInstance.CompleteRequest();
    

提交回复
热议问题