当我尝试进行排序时出现以下错误。 对象引用未设置到对象的实例。
public static string SortColumn
{
get
{
return HttpContext.Current.Session["SORT_COLUMN"].ToString();
}
set
{
HttpContext.Current.Session["SORT_COLUMN"] = value;
}
}
请帮我解决这个...
最佳答案
Session["SORT_COLUMN"]
可以返回 null
并且您不能在 nothing 上调用something,所以 ToString
会失败。
此外,HttpContext.Current
可能会返回 null
,这意味着您无法访问 Session
- 如果您尝试从 global.asax 代码访问上下文。
关于c# - 你调用的对象是空的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7245315/