从ViewData的的NullReferenceException这是不实际空 [英] NullReferenceException from ViewData which is Not Null actually
本文介绍了从ViewData的的NullReferenceException这是不实际空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我觉得截图说明了一切。我怎样才能解决这个问题呢?即使数据不为空,它给空引用异常。
堆栈跟踪是如下:
在ASP._Page_Views_Profile_Index_cshtml.Execute()在C:\\ AAAAAA \\ AAA \\ AAAAAA \\查看\\简介\\ Index.cshtml:17行
在System.Web.WebPages.WebPageBase.ExecutePageHierarchy()
在System.Web.Mvc.WebViewPage.ExecutePageHierarchy()
在System.Web.WebPages.StartPage.ExecutePageHierarchy()
在System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext的pageContext,TextWriter的作家,WebPageRenderingBase起始页)
在System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext上下文)
在System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass1a.<InvokeActionResultWithFilters>b__17()
在System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter过滤器,ResultExecutingContext preContext,Func`1续)
解决方案
我打赌了线程问题。当视图引擎尝试显示/绑定值(MobilePhone)是null,并且它抛出异常,但在此期间,负责调试器加载数据的完成和期望时/查看值的值线程是present。
I think the screenshot explains everything. How can i resolve this problem ? Even the data is not null, it gives null reference exception..
Stacktrace is below:
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)
解决方案
I'm betting for a threading issue. When the ViewEngine tries to display/bind the value(MobilePhone) it's null and it throws the exception but in the meantime the thread responsible for loading the data finishes and when expecting/viewing the value in the debugger the value is present.
这篇关于从ViewData的的NullReferenceException这是不实际空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文