Allen Rice Allen Rice - 3 years ago 306
ASP.NET (C#) Question

How do I manually log a user in with a MembershipProvider?

I'm experimenting with writing my own custom

in and I want to roll my own login page. We do some fairly special stuff at login time so we can't use the default login control so I need a way to manually log a user in.

So far I haven't found anything on how to write your own login control so I'm here, wondering how I can manually log a user in via a

I've tried

Membership.ValidateUser("user", "pass");

and while that does call
on my custom
, and it does return true, it doesn't actually log me in.

Btw I'm fairly new to the whole
stuff so if I'm not even on the right wavelength, feel free to let me know.

Answer Source

A MembershipProvider only stores the data about the users, actual logins and session handling are handled by an AuthenticationProvider. For example, if you're using forms (=cookie based) authentication, check out FormsAuthentication.SetAuthCookie and the other related methods in that class.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download