0

I am developing a new web project using ASP.NET MVC 4.

I already have an existing MySQL database that contains a user table of UserId, UserName and Password. I need to validate certain pages/views (not all) in my MVC project against this data.

Can anyone point me in the right direction to achieve this. I don't want to implement anything too complicated. Thanks for any help.

neildt
  • 5,101
  • 10
  • 56
  • 107
  • SimpleMembership and using the MySql context should get you 99% of the way there (have a look at http://stackoverflow.com/questions/12620922/using-simple-membership-provider-with-mysql) – Brad Christie Jul 28 '13 at 01:11
  • I've been reading about [Authorize] which I can apply to all Controllers using the Filter. Then I can allow Anonymous access to selected controllers. Are there any examples of then using my MySQL database for the user login ? – neildt Jul 28 '13 at 10:17
  • Does anyone have any examples or sample code. Basically I'm not interested in Windows authentication or oAuth. I just want to query my database to check if the user exists and get their access level which will define what Controllers they have access to. – neildt Jul 28 '13 at 15:53
  • I just gave you the link on how to do that. You Create an MVC site, then wire up SimpleMembership using MySQL (instead of MsSQL). From there, all the membership qualities (like logging in/out, `AuthorizeAttribute`, etc.) will be available. If you need control further, create a custom [`MembershipProvider`](http://msdn.microsoft.com/en-us/library/system.web.security.membershipprovider.aspx) and auth your own way. – Brad Christie Jul 28 '13 at 16:55
  • I looked at that example but seemed to be very complicated. Are there any more basic ways to achieve my goal – neildt Jul 28 '13 at 17:33
  • I've just come across this document, http://www.codeproject.com/Articles/482546/Creating-a-custom-user-login-form-with-NET-Csharp Are there any pitfalls using this approach , as it does exactly what I require. – neildt Jul 29 '13 at 16:42

0 Answers0