62,244
社区成员




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 "";
}
试试!