【发布时间】:2014-06-19 21:04:41
【问题描述】:
我有一个名为 ErrorController 的控制器,其操作为 Index。
我正在捕获来自其他控制器的异常,即HomeController,并将异常存储在名为ExceptionDetails的模型中,如下所示。
public class ExceptionDetail
{
public string message { get; set; }
public string details { get; set; }
}
一旦捕获到异常,我会将其存储在上面显示的模型中,并希望将其发送到控制器ErrorController 的操作Index。
我该怎么做呢
我尝试了以下方法,但没有成功。
catch (System.Exception exception)
{
exceptionDetail.details = exception.ToString();
exceptionDetail.details = exception.Message.ToString();
return RedirectToAction("Index", "Error", new { exception = exceptionDetail });
}
Index 操作如下所示,我也有索引的强类型视图。
public ActionResult Index(ExceptionDetail exceptionDetail)
{
return View(exceptionDetail);
}
提前感谢您的帮助。
【问题讨论】:
-
您能否详细说明“没用”
-
我找到了解决方案@Jonesy 将发布答案
标签: c# asp.net-mvc asp.net-mvc-4 model action