0
我Login.cs
定義session["username]"
當用戶想要登錄獲得本屆
public static void SetLogin(string username, bool remmember)
{
HttpContext.Current.Session["username"] = username;
}
,我想在UserPanelController使用session["username"]
值
public class UserPanelController : Controller
{
Customer cu;
Customer.customer cust;
public UserPanelController()
{
if (Login.ChekLogin())
{
cust = cu.Read(int.Parse(Session["username"].ToString()));
// error Occur here Session is null
}
}
}
我無法訪問會話,因爲爲null