8
會議在Application_AuthenticateRequest方法在Global.asax中總是null.Ive已經嘗試:ASP.NET會話在Global.asax中
this.Session,HttpContext.Current.Session
總是空。
protected void Application_AuthenticateRequest()
{
string userRole = string.Empty;
if (Request.IsAuthenticated)
{
if (this.Session["UserRole"] == null)
{
InsertSessionValue();
}
userRole =Session["UserRole"].ToString();
HttpContext.Current.User = new GenericPrincipal(User.Identity, new string[] {userRole});
}
}
我也嘗試使用緩存,但它不工作,因爲我需要每個用戶的獨特信息。
如何在Global.asax中使用Session?HttpApplication應用程序屬性對每個用戶都是唯一的嗎?
ID說它可能你沒有正確地調用該方法。當沒有請求正在處理時,發生NULL的原因。你如何調用該方法/分配該委託? – RPM1984 2010-09-13 01:00:27
調用Application_AuthenticateRequest?當用戶嘗試進行身份驗證時它會自動觸發; – ozsenegal 2010-09-13 01:04:33