简体   繁体   中英

issue with forms authentication - Unable to redirect from login page to home page after authentication

In Sharepoint 2010 we created a web application with classic authentication and started developing it. Later, we want to implement forms authentication to our project, so I created a new SharePoint Web Application with form based authentication enabled. I took the backup of the old site (classic auth.) and restored to the new site (fba). I implemented forms authentication by following the below link:

Configuring Forms Based Authentication for SharePoint 2010 using IIS7

I created a custom sign-in page. After entering valid credentials the user is not redirected to the Home page. Authentication is happening properly but it is not redirecting to the home page. When I click on the login button, it is again loading the same login page. Please find the below code for authenticating and redirecting to home page:

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.";
  }
}

We are unable to figure out the issue. I tried so many solutions but they are of no use.

Please Use SPClaimsUtility for Authorization of Users in Claims based application.

Add the Microsoft.SharePoint.IdentityModel DLL reference from .\\assembly\\GAC_MSIL\\Microsoft.SharePoint.IdentityModel\\14.0.0.0__71e9bce111e9429c \\Microsoft.SharePoint.IdentityModel.dll to access SPClaimsUtility

than try this:

  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);
              }
        });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM