我的應用程序中有三個頁面。登錄後重定向到特定頁面
的Login.aspx
Report.aspx
Main.aspx
當用戶在www.abc123.com/Report.aspx URL點擊,如果他們沒有簽署,我指導他們到www.abc123.com/Login.aspx頁面,但他們登錄後,我想顯示Report.aspx頁面,而不是Main.aspx頁面。以下我的代碼:
protected String Username
{
get
{
return Convert.ToString(Session["LoggedInUser"]);
}
}
protected void Page_Load(object sender, EventArgs e)
{
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetExpires(DateTime.Today.AddDays(-1));
Response.Cache.SetNoStore();
if (String.IsNullOrEmpty(Username))
{
Response.Redirect("Login.aspx");
}
爲什麼不使用基於窗體的身份驗證(http://support.microsoft.com/kb/301240/en)以及特定頁面上的權限(例如, Reports.aspx?這應該支持您的要求,並且是一種經過驗證的ASP.NET技術。您還可以避免再次在每個受保護頁面上實施安全代碼。 – Markus
嗨馬庫斯......我不知道該怎麼做。 – Valley
試試這個http://stackoverflow.com/questions/20226946/redirecting-to-specific-page-after-login –