[英]issue with forms authentication - Unable to redirect from login page to home page after authentication
在Sharepoint 2010中,我們使用經典身份驗證創建了一個Web應用程序,並開始開發它。 稍后,我們希望對項目實現表單身份驗證,因此我創建了一個新的SharePoint Web應用程序,並啟用了基於表單的身份驗證。 我拿了舊網站的備份(經典版權所有)並恢復到新網站(fba)。 我按照以下鏈接實現了表單身份驗證:
使用IIS7為SharePoint 2010配置基於表單的身份驗證
我創建了一個自定義登錄頁面。 輸入有效憑據后,用戶不會重定向到主頁。 身份驗證正常進行,但不會重定向到主頁。 當我點擊登錄按鈕時,它再次加載相同的登錄頁面。 請找到以下代碼進行身份驗證和重定向到主頁:
protected void btnLogin2_Click(object sender, EventArgs e)
{
if (Membership.ValidateUser(txtUserId.Value, txtPassword.Value))
{
string link = "http://ejudnam:36414/sites/Prototype/Dashboard/Pages/default.aspx");
Response.Redirect(link);
//I tried with the below line also but it is of no use
// SPUtility.Redirect(link, SPRedirectFlags.Default, this.Context);
}
else
{
lblMessage.Text = "Login Failed.";
}
}
我們無法弄清楚這個問題。 我嘗試了很多解決方案,但它們毫無用處。
請使用SPClaimsUtility在基於聲明的應用程序中授權用戶。
從。\\ assembly \\ GAC_MSIL \\ Microsoft.SharePoint.IdentityModel \\ 14.0.0.0__71e9bce111e9429c \\ Microsoft.SharePoint.IdentityModel.dll添加Microsoft.SharePoint.IdentityModel DLL引用以訪問SPClaimsUtility
試試這個:
SPSecurity.RunWithElevatedPrivileges(delegate()
{
bool status = SPClaimsUtility.AuthenticateFormsUser(Context.Request.UrlReferrer, txtUserId.Value, txtPassword.Value);
if (status)
{
string link = "http://ejudnam:36414/sites/Prototype/Dashboard/Pages/default.aspx";
Response.Redirect(link);
}
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.