你是否看到会话断断续续地失去价值的原因?
public ActionResult Index(string app) // this view hits the Create Controller on a form post event
{
Session["appType"] = app;
return View();
}
[HttpPost]
public ActionResult Create(string userName, string password)
{
string a = Session["appType"].ToString(); // throws object reference error.
}
答案 0 :(得分:2)
您会看到以下代码:
<sessionState mode="SQLServer"
cookieless="true "
regenerateExpiredSessionId="true "
timeout="30"
sqlConnectionString="Data Source=MySqlServer;Integrated Security=SSPI;"
stateNetworkTimeout="30"/>