的NullReferenceException上..支架? [英] nullreferenceexception on.. bracket?
本文介绍了的NullReferenceException上..支架?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
@if(Model.LastOrder!= NULL)
{
< H3> Lorem存有:LT; / H3>
}
其他
{
< H3> LOREM LOREM<!/ H3>
} - GT;这里出现错误
通过这个code,我得到一个错误的NullReferenceException
。一切都可以很容易解决,但发生在去年...支架的错误!很奇怪......更有甚者 - 没有什么特别的是错误的信息来帮助我。
为什么我得到这个错误?
下面是我的控制器操作:
[授权]
公众的ActionResult仪表板()
{
XYZ toReturn =新的XYZ {};
返回查看(toReturn);
}
解决方案
尝试删除括号,因为你只有一个行后,如果和其他人,看看会发生什么,这会给你更多的信息,然后。
@if (Model.LastOrder != null)
{
<h3>Lorem ipsum:</h3>
}
else
{
<h3>Lorem lorem!</h3>
} -> here occurs error
With this code, I get an error nullreferenceexception
. Everything could be easy to resolve, but error occurs at... last bracket! Very strange.. and what is more - nothing special is in error info to help me.
Why I get this error?
Here is my controller action:
[Authorize]
public ActionResult Dashboard()
{
XYZ toReturn = new XYZ { };
return View(toReturn);
}
解决方案
Try removing brackets, since you have just one line after if and else, and see what happens, that will give you more information then.
这篇关于的NullReferenceException上..支架?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文