Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • David F. Hill 122 posts 242 karma points
    Oct 07, 2010 @ 00:35
    David F. Hill
    0

    Login Programmatically with FormsAuthentication.Authenticate

    Hello Umbraco Colleagues,

    As I understand, Umbraco (v 4.0.2.1) membership supports the ASP.Net membership provider. The ASP.Net Login control works well for this but...
    I need to programmatically login members after they complete the registration form.

    I have tried System.Web.Security.FormsAuthentication.Authenticate() but it fails to authenticate.

    I've read this forum post:
    http://our.umbraco.org/forum/developers/api-questions/9595-Programmatically-login-user-with-MemberAddMemberToCache()
    But it seems odd to revert to an Umbraco API call since we're using the ASP.Net membership provider.

    What's the solution?

    Thanks,

    David Hill

  • Matt Brailsford 4125 posts 22224 karma points MVP 9x c-trib
    Oct 07, 2010 @ 09:50
    Matt Brailsford
    1

    Hi David,

    You should be able to validate a User by communicating with the Membership provider, so something like:

    Membership.ValidateUser(username, password);

    You should then be able to set the auth cookie using:

    FormsAuthentication.RedirectFromLoginPage(username, createCookie);

    Hope this helps.

    Matt

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies