0
使用標準的ASP.NET登錄控制,我試圖讓它拒絕我登錄,如果用戶誰試圖登錄成員的取消組。ASP.NET登錄控制 - 拒絕登錄,如果在一個角色
<asp:Login ID="Login1" runat="server" OnLoggedIn="Login1_LoggedIn" DestinationPageUrl="~/Default.aspx" FailureText="Whoops - something went wrong with your login. <br />Please try again. <br />If you've forgotton you password please click link below and we'll send you a new one" >
<LayoutTemplate>
<table cellpadding="1" cellspacing="0" style="border-collapse:collapse;">
<tr>
和後面的代碼(僞代碼..不工作)
protected void Login1_LoggedIn(object sender, EventArgs e)
{
var profile = WebProfile.GetProfile(UserManager.GetCurrentUserName());
if User.IsInRole("cancelled") {
FormsAuthentication.SignOut();
// write out a message saying you are not allowed to login
}
}
不錯的一個...乾杯 – 2010-08-19 07:05:53