Exchange服务器在错误页面中显示错误消息

时间:2018-01-16 12:33:49

标签: asp.net exchange-server

如何在我的Exchange服务器的自定义错误页面中显示异常消息?

我在自定义错误页面上定义并设置错误时间以交换用户,但我会在自定义错误页面中显示异常消息和最后一个异常的堆栈跟踪。

我使用以下代码但是为null:

if (HttpContext.Current.Server.GetLastError() != null)
Response.Write("Error");

当if为true时,我希望显示在交换应用程序中引发的异常消息和异常堆栈跟踪。

1 个答案:

答案 0 :(得分:0)

RouteData routeData = new RouteData();
routeData.Values.Add("controller", "Home");
routeData.Values.Add("action", "Error");
routeData.Values.Add("model", new HandleErrorInfo(ex, errorController, errorAction));

Response.TrySkipIisCustomErrors = true;
IController controller = new Controllers.HomeController();
controller.Execute(new RequestContext(new HttpContextWrapper(Context), routeData));
Response.End();

使用此代码,您可以打开自定义错误页面,并显示上次服务器错误。

您的错误操作应该如下所示;

public ActionResult Error(HandleErrorInfo model)
{
    return View(model);
}