这是我得到的错误“会话状态在此上下文中不可用。”
只是一个业余程序员,我如何在 Global.asax 中检索 Session
这是我在 Global.asax 中的代码
public class Global : System.Web.HttpApplication
{
protected void FormsAuthentication_OnAuthenticate(Object sender, FormsAuthenticationEventArgs e)
{
if (FormsAuthentication.CookiesSupported == true)
{
if (Request.Cookies[FormsAuthentication.FormsCookieName] != null)
{
try
{
string Email = FormsAuthentication.Decrypt(Request.Cookies[FormsAuthentication.FormsCookieName].Value).Name;
string Roles = LoginVerification.GetUserRoles(Email);
string DisplayName = (string)Session["DisplayName"];
e.User = new System.Security.Principal.GenericPrincipal(
new System.Security.Principal.GenericIdentity(DisplayName, "Forms"), Roles.Split(';'));
}
catch (Exception)
{
}
}
}
}
protected void Application_Start(object sender, EventArgs e)
{
}
protected void Session_Start(object sender, EventArgs e)
{
}
protected void Application_BeginRequest(object sender, EventArgs e)
{
}
protected void Application_AuthenticateRequest(object sender, EventArgs e)
{
}
protected void Application_Error(object sender, EventArgs e)
{
}
protected void Session_End(object sender, EventArgs e)
{
}
protected void Application_End(object sender, EventArgs e)
{
}
}
提前感谢您回答我的问题!:)