當用戶點擊工資單(安全頁面)選項時,他/她會被提示登錄&然後被重定向到帳戶頁面。我在Login_Authenticate
方法中使用Page.ResolveUrl
。登錄後,如果用戶導航到網站&上的任何不同頁面,然後再次點擊工資單,我檢查頁面加載中的Identity.IsAuthenticated
狀態,並根據此情況再次將用戶重定向到帳戶頁面。我想知道這是否是正確的方式,或者是否有任何最佳做法,因爲這涉及到大量的服務器調用。我可以在asp:LoginView
或Javascript中使用LoggedInTemplate
來執行此功能嗎?我有您的參考代碼...認證成功後重定向
protected void Page_Load(object sender, EventArgs e)
{
//to directly link user to account if it's authenticated
var userauth = System.Web.HttpContext.Current.User.Identity.IsAuthenticated;
if (userauth)
{
string urlredirect = Page.ResolveUrl("~/" + SiteConfig.PageMappings["ACCOUNT"]);
Response.Redirect(urlredirect);
Server.TransferRequest(urlredirect);
}
}
感謝您的時間和知識... – Scorpio 2012-07-20 14:00:46