Search code examples
c#asp.net-mvcauthenticationasp.net-membershipcustom-membershipprovider

Whats the right way to implement a login form in MVC?


I've been looking into building a custom MembershipProvider, and also an AccountController... and I'm just wondering, what's the right way to build a user login function into an MVC web application?

I can see how to build something using an AccountController, and I can see how to build something with a custom Membership provider, and I can see how to use both of them together. Should both of these be used? Has onw superseded the other? Is there a better, or more "standard" way of building a login function?

This is where I read about using an Account Controller and MembershipProvider together: http://kitsula.com/Article/Custom-Membership-Provider-for-MVC

This is where I read about using an Account Controller: http://www.asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-7

And this is where I read about using a custom Membership Provider: http://www.asp.net/web-forms/videos/how-do-i/how-do-i-create-a-custom-membership-provider

All 3 solutions seem valid with MVC, but are some/all/one of these solutions outdated? or not supposed to be used with MVC etc...

I appreciate any assistance.


Solution

  • Basically, you can use any membership provider with ASP.Net MVC.

    Back to the original question, I don't think there is right way or wrong way. If you want to implement Custom Membership Provider in new MVC5, you can.

    If you are developing a new application and want latest technologies such as token based verification and two-factor authentication, you might want to look into ASP.Net Identity 2.

    FYI: None of them are backward compatible (except ASP.NET Universal Providers which is somewhat compatible with legacy Membership Provider).