我的MVC项目存在问题!我们的目标是建立一个会话变种,以便将它传递给所有控制器: 我xUserController内,会话变量在两个不同的控制器之间仍然为空
Session["UserId"] = 52;
Session.Timeout = 30;
string SessionUserId = ((Session != null) && (Session["UserId"] != null)) ? Session["UserId"].ToString() : "";
// SessionUserId = “52”
但ChatMessageController内
[HttpPost]
public ActionResult AddMessageToConference(int? id,ChatMessageModels _model){
var response = new NzilameetingResponse();
string SessionUserId = ((Session != null) && (Session["UserId"] != null)) ? Session["UserId"].ToString() : "";
//...
}
return Json(response, "text/json", JsonRequestBehavior.AllowGet);
}
SessionUserId =“”
那么,为什么呢?如何在所有控制器中将会话变量设置为全局?
会话varialbe是全球唯一 – Devesh 2013-04-25 09:34:47
当然,但你怎么解释SessionUserId =“”在其他控制器?我必须写什么? – Bellash 2013-04-25 09:41:18
您使用哪种浏览器? – Sharun 2013-04-25 09:59:06