【发布时间】:2013-07-09 13:19:28
【问题描述】:
我正在尝试重定向到一个视图并不断收到问题标题中发布的错误。
在断点测试期间,通过代码 iv 的第一位的代码位于设置消息和设置异常的下方。返回重定向后继续后显示的下一页如下。
在 ErrorController 和错误模型中添加断点我发现代码永远不会到达那里。
我试图发布到的视图是一个错误页面。这是帮助您查看问题的代码。
RedirectToAction:
string message;
message = "An error has occured during the communication to lightstone, this is likely a timeout issue and could be the result of a bad connection. Please go back and try again.";
return RedirectToAction("Error", "Error", new { ex = ex.ToString(), message = message});
我的 ErrorController 中的操作:
public ActionResult Error(string ex, string message)
{
ViewBag.Message = "Error";
return View(new ErrorModel(ex, message));
}
我的错误模型:
namespace MvcResComm.Models
{
public class ErrorModel
{
public string ex { get; set; }
public string message { get; set; }
public ErrorModel(string ex, string message)
{
this.ex = ex;
this.message = message;
}
}
}
【问题讨论】:
-
您可以查看stackoverflow.com/questions/8159321/… 以获得答案。
-
我现在明白了这个问题,但仍然没有有效的解决方案来解决它。
标签: c# asp.net-mvc-3