0
我想在IIS(和Azure)下處理404錯誤,但下面的代碼不起作用。 在本地主機上,這工作得很好。 我該如何解決這個問題?404例外(IIS)
從HTTP模塊
protected void Application_Error(Object source, EventArgs e)
{
HttpApplication application = (HttpApplication)source;
HttpContext context = application.Context;
Exception ex = application.Server.GetLastError().GetBaseException();
if (ex != null && ex is HttpException)
{
var httpEx = ex as HttpException;
if (httpEx != null && httpEx.GetHttpCode() == 404)
{
context.Response.StatusCode = 404;
application.Response.Redirect(BXSite.Current.GetUrl("/404/"));
application.Server.ClearError();
}
}
}
我相信這個鏈接會引導你 http://stackoverflow.com/questions/10059009/enable-custom-errors-in-azure – Madan 2012-07-17 12:36:15
你是什麼意思不工作?你看到任何錯誤消息? – 2012-07-19 14:43:04