比较来自世界各地的卖家的域名和 IT 服务价格

如何找到其中的控制器 / 错误发生?

我注册了我的方法中出现的所有错误 OnException.

如何找到其中的控制器 / 错误发生?
已邀请:

窦买办

赞同来自:

正如预期的Charlino,值可从参数中获得。 ExceptionContext:


protected override void OnException/ExceptionContext filterContext/
{
var controllerName = filterContext.RouteData.Values["controller"];
var actionName = filterContext.RouteData.Values["action"];

// ...

base.OnException/filterContext/;
}

帅驴

赞同来自:

查看异常调用堆栈。

例如:


var actionMethod = new StackTrace/exception/
.GetFrames//.FirstOrDefault/f =>
typeof/IController/.IsAssignableFrom/f.GetMethod//.DeclaringType/
/.GetMethod//;

快网

赞同来自:

将以下方法添加到您的 global.asax 并放置一个停止点


public void Application_Error/object sender, EventArgs e/
{


}


无论应用程序中发生错误,都将实现此方法的停止点。 从这里,您可以在快速查看窗口中看到以下表达式的值,并找出究竟究竟是什么


//System.Web.HttpApplication//sender//.Context.AllErrors


无论发生Web应用程序中的异常,此方法都将有助于帮助。

要回复问题请先登录注册