62,072
社区成员
发帖
与我相关
我的任务
分享
public static string GetSession(string strName)
{
if (HttpContext.Current.Session[strName] != null)
return HttpContext.Current.Session[strName].ToString();
return "";
}
public static string GetSession(string strName)
{
if (HttpContext.Current.Session != null && HttpContext.Current.Session[strName] != null)
return HttpContext.Current.Session[strName].ToString();
return "";
}
解决了要先判断 HttpContext.Current.Session != nullpublic static string GetSession(string strName)
{
if (HttpContext!=null && HttpContext.Current!=null && HttpContext.Current.Session[strName] != null)
return HttpContext.Current.Session[strName].ToString();
return "";
}
试试!