【发布时间】:2012-03-15 13:48:50
【问题描述】:
我收到以下代码行的错误:对象引用未设置为对象的实例。
if (Session["AutoCompleteCustomersPhone"] != null)
完整的代码块:
if (Session["AutoCompleteCustomersPhone"] != null)
earchCustomerPhone = true;
else
{
searchCustomerPhone =
bool.Parse(Session["AutoCompleteCustomersPhone"].ToString());
}
为什么在对 null 的测试中,我收到此错误?
【问题讨论】:
-
很可能,
Session本身就是null。 -
这段代码到底在哪里运行?它可能会给我们一个线索,为什么 Session 为空......
-
这是在 ASMX Web 服务还是 WCF 中?
标签: c# asp.net web-services