如何从Global.asax中设置 tempdata?
asp.net-mvc-2
答案 0 :(得分:4)
Dictionary<string, object> tempDataDictionary = Context.Session["__ControllerTempData"] as Dictionary<string, object>;
if (tempDataDictionary == null)
{
tempDataDictionary = new Dictionary<string, object>();
}
**tempDataDictionary["TopMessage"] = message;
tempDataDictionary["FromUnauthorized"] = true;
HttpContext.Current.Session["__ControllerTempData"] = tempDataDictionary;**
Server.ClearError();
Response.Redirect("~/Account/LogOn");