1 protected void Application_AcquireRequestState(Object sender, EventArgs e) 2 { 3 HttpApplication happ = (HttpApplication)sender; 4 HttpContext context = happ.Context; 5 string url = context.Request.RawUrl; 6 string path = url.Split('/')[1]; 7 switch (path) 8 { 9 case "user":10 case "User":11 12 if (HttpContext.Current.Session != null)13 {14 if (HttpContext.Current.Session["user"] == null)15 {16 Response.Redirect("/login/index.aspx");17 }18 }19 else20 {21 Response.Redirect("/login/index.aspx");22 }23 break;24 case "admin":25 break;26 default:27 break;28 }29 }
我是想對請求路徑進行過濾,比如說是當訪問user文件夾下的文件一定登陸才行,看我上面寫的,可是由于我在user文件夾下的某個文件里用了AJAX,這時候 if (HttpContext.Current.Session != null) 這句就一直成立了,我想知道怎么才能在用ajax的時候也傳送上下文
global.asax文件中session問題
慕尼黑8549860
2018-12-07 05:10:49