0

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.

http://donalconlon.wordpress.com/2010/02/23/configuring-forms-base-authentication-for-sharepoint-2010-using-iis7/

I created a custom sign-in page. After entering valid credentials, user is not redirected to Home page. Authentication is happening properly but it not redirecting to the home page. When I click on 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. Your help will be highly appreciated.

Thank You.

1
  • Do you see any errors in the ULS logs that coincide with when you are attempting to log in? The FBA setup for SharePoint 2010 can be an error-prone process and I have found the ULS logs generally give a decent amount of information to troubleshoot the log in process. May 28, 2012 at 12:45

3 Answers 3

1

Your custom login logic does not seem to set the FedAuth cookie:

SecurityToken token = SPSecurityContext.SecurityTokenForFormsAuthentication(
    new Uri(SPContext.Current.Web.Url),
    membershipProviderName,
    roleProviderName,
    this.loginForm.UserName,
    this.loginForm.Password);

SPFederationAuthenticationModule.Current.SetPrincipalAndWriteSessionToken(token);

RedirectToSuccessUrl();
0

If you get the login page again, then most likely there is a resource (image, list....) that you don't have sufficient permissions to view, on the page you're redirected to after logging in. As a result you're being redirected back to the login page.

Try making the user you're logging in as a site collection administrator, to see if it gets around this issue. If it does, then you have to find the offending resource and adjust the permissions on it.

Also, you mentioned you have a custom sign in page. Make sure that you can sign in properly with SharePoint's default sign in page - in case the custom sign in page is causing the issue.

0

Use Response.redirect( SpContext.current.site.url)

1
  • 1
    While this post may answer the question, we prefer more details such as "why". Please edit your post with additional details. See answer for general guidelines.
    – SPDoctor
    May 25, 2012 at 9:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.