[英]How to login with login control and when logged in go to myPage.aspx not Default.aspx in asp.net?
如何使用登录控件登录,并且登录后进入asp.net中的myPage.aspx而不是Default.aspx?
我想在登录时转到myPage并向我提供用户信息。
登录控件具有属性DestinationPageUrl 。 将所需的页面设置为DestinationPageUrl。
<asp:Login DestinationPageUrl="~/myPage.aspx" ID="LoginUser" runat="server" EnableViewState="false" RenderOuterTable="false">
---------------------
---------------------
---------------------
</asp:Login>
另外,如果要在页面上显示userName,则可以使用HeadLoginView控件Like。
<asp:LoginView ID="HeadLoginView" runat="server" EnableViewState="false">
<LoggedInTemplate>
Welcome <span class="bold"><asp:LoginName ID="HeadLoginName" runat="server" /></span>!
</LoggedInTemplate>
</asp:LoginView>
要么
使用以下代码行获取当前的登录用户。
System.Web.Security.Membership.GetUser().ToString();
对于注销使用FormsAuthentication
protected void LogOut_Click(object sender, EventArgs e)
{
Session.Clear();
Session.Abandon();
System.Web.Security.FormsAuthentication.SignOut();
System.Web.Security.FormsAuthentication.RedirectToLoginPage();
//if you want to redirect to your desired page just use following line instead of RedirectToLoginPage
//Response.Redirect("myPage.aspx");
}
另请参阅下面的链接,可能会得到更多帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.