Search code examples
c#authenticationasp.net-membershipforms-authenticationhttpmodule

Automatically assign authentication token in .NET


I have implemented forms authentication with a .NET Membership Provider but I also want users to be able to login with Facebook. Once authenticated with Facebook, I want to automatically assign a .NET authentication token to the user. I have a HttpModule that is detecting the FB authentication but all my attempts to manually generate an authentication token have come up short.

I tried

  • FormsAuthentication.SetAuthCookie
  • FormsAuthentication.GetAuthCookie + Response.Cookies.Add
  • new FormsAuthenticationTicket(...) a la MSDN
  • In an HttpModule vs Page

Plus a few other desperate attempts. Nothing seems to work. How is this done?


Solution

  • It turns out someone else had registered another module in the solution that was interfering with HttpRequest and the authentication pieces. After I got rid of that, FormsAuthentication.SetAuthCookie(...) worked fine.

    Thanks everyone for the help.