2010-09-13 62 views
0
protected void Page_Load(object sender, EventArgs e) 
{ 
    if (!Page.IsPostBack) 
    { 
     Response.Cache.SetCacheability(HttpCacheability.NoCache); 
     Response.Cache.SetAllowResponseInBrowserHistory(false); 
    } 

這段代碼我用來驗證網站,它的工作,但只有當用戶複製網址並將其粘貼到新窗口,但在新窗口中打開導致下一頁沒有任何登錄憑證。身份驗證在asp.net

+2

你爲什麼不使用內置的身份驗證?它會強制用戶在您進入Page_Load方法之前進行身份驗證。 – 2010-09-13 10:45:51

+1

問題不清楚。你想做什麼? – 2010-09-13 19:27:35

回答

0

對於身份驗證: 在page_Load活動

if (session(user_id) != null) { 
    response.redirect("the_page_which_you_want_to_go.aspx"); 
} else { 
    response.redirect("Login.aspx"); 
} 
+0

請使用SO的代碼格式,它會讓你的答案更加清晰。 – Richard 2010-09-20 12:47:04