【发布时间】:2012-07-19 16:43:29
【问题描述】:
当用户点击支付账单(安全页面)选项时,系统会提示他/她登录,然后被重定向到帐户页面。我在Login_Authenticate 方法中使用Page.ResolveUrl。登录后,如果用户导航到网站上的任何其他页面,然后再次单击付款账单,我会检查页面加载中的 Identity.IsAuthenticated 状态,并据此再次将用户重定向到帐户页面。我想知道这是否是正确的方法,或者是否有任何最佳实践,因为这涉及到大量的服务器调用。我可以使用asp:LoginView 中的LoggedInTemplate 或Javascript 来执行此功能吗?我有你参考的代码...
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);
}
}
【问题讨论】:
标签: c# asp.net authentication redirect login