ViewData中的NullReferenceException实际上是非空的

时间:2012-11-06 15:47:37

标签: c# asp.net asp.net-mvc

ScreenShot

我认为截图解释了一切。我该如何解决这个问题?即使数据不为null,它也会给出null引用异常..

Stacktrace如下:

   at ASP._Page_Views_Profile_Index_cshtml.Execute() in c:\aaaaaa\aaa\aaaaaa\Views\Profile\Index.cshtml:line 17
   at System.Web.WebPages.WebPageBase.ExecutePageHierarchy()
   at System.Web.Mvc.WebViewPage.ExecutePageHierarchy()
   at System.Web.WebPages.StartPage.ExecutePageHierarchy()
   at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage)
   at System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context)
   at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass1a.<InvokeActionResultWithFilters>b__17()
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation)  

1 个答案:

答案 0 :(得分:0)

我打赌有线程问题。当ViewEngine尝试显示/绑定值(MobilePhone)时,它为null并且它抛出异常,但同时负责加载数据的线程完成,并且当期望/查看调试器中的值时,该值存在。