Argh! 为什么 System.Web.Mvc.HandleErrorInfo 被传递到我的视图中?

10 浏览
0 Comments

Argh! 为什么 System.Web.Mvc.HandleErrorInfo 被传递到我的视图中?

我遇到了一个非常令人沮丧的问题。我的MVC网站大部分时间都可以正常运行,但会随机抛出一个错误(对用户显示友好的错误信息)。当我检查日志时,得到的内容如下:

System.InvalidOperationException: 传递给字典的模型项的类型为'System.Web.Mvc.HandleErrorInfo',但此字典需要一个类型为'BaseViewData'的模型项。

过了一会儿,同一个用户可以点击刷新按钮,页面就正常加载了。我卡住了。 ;(

更新:添加堆栈跟踪

System.Web.HttpUnhandledException: 类型为'System.Web.HttpUnhandledException'的异常被抛出。---> System.InvalidOperationException: 传递给字典的模型项的类型为'System.Web.Mvc.HandleErrorInfo',但此字典需要一个类型为'BaseViewData'的模型项。
   在System.Web.Mvc.ViewDataDictionary`1.SetModel(Object value)
   在System.Web.Mvc.ViewDataDictionary..ctor(ViewDataDictionary dictionary)
   在System.Web.Mvc.HtmlHelper`1..ctor(ViewContext viewContext, IViewDataContainer viewDataContainer, RouteCollection routeCollection)
   在System.Web.Mvc.ViewMasterPage`1.get_Html()
   在ASP.views_shared_site_master.__Render__control1(HtmlTextWriter __w, Control parameterContainer)
   在System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
   在System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
   在System.Web.UI.Control.Render(HtmlTextWriter writer)
   在System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
   在System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)
   在System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
   在System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
   在System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
   在System.Web.UI.Page.Render(HtmlTextWriter writer)
   在System.Web.Mvc.ViewPage.Render(HtmlTextWriter writer)
   在System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
   在System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)
   在System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
   在System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
   --- 内部异常堆栈跟踪结束 ---
   在System.Web.UI.Page.HandleError(Exception e)
   在System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
   在System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
   在System.Web.UI.Page.ProcessRequest()
   在System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context)
   在System.Web.UI.Page.ProcessRequest(HttpContext context)
   在ASP.views_shared_error_aspx.ProcessRequest(HttpContext context)
   在System.Web.Mvc.ViewPage.RenderView(ViewContext viewContext)
   在System.Web.Mvc.WebFormView.RenderViewPage(ViewContext context, ViewPage page)
   在System.Web.Mvc.WebFormView.Render(ViewContext viewContext, TextWriter writer)
   在System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context)
   在System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult)
   在System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName)
   在System.Web.Mvc.Controller.ExecuteCore()
   在System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext)
   在System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext)
   在System.Web.Mvc.MvcHandler.ProcessRequest(HttpContextBase httpContext)
   在System.Web.Mvc.MvcHandler.ProcessRequest(HttpContext httpContext)
   在System.Web.Mvc.MvcHandler.System.Web.IHttpHandler.ProcessRequest(HttpContext httpContext)
   在System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   在System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

0