All of the examples I’ve found are in C# and I need one if VB. How can I turn my code below to inherit all of the Membership provider functions?
Imports System.Data.Entity
Imports MyBlog
Namespace MyBlog
Public Class EmployeeController
Inherits System.Web.Mvc.Controller
Private db As EmployeeDbContext = New EmployeeDbContext
'
' GET: /Employee/LogOn
Public Function LogOn() As ActionResult
Return View()
End Function
End Class
End Namespace
Here are the articles that I’ve read Custom membership or not, Implementing custom login for ASP.NET MVC. I can’t seem to inherit more than one class in VB (don’t often use inheritance or implement or interfaces).
You need to write a class that inherits from MembershipProvider and override the methods you are interested in:
And then you register your custom provider in web.config:
Now from within your controllers you simply use the
Membershipclass. For example in yourLogOnaction that was generated by the default template when you created your project you don’t need to change absolutely anything:All calls to
Membershipwill now use your custom membership provider that you registered in web.config.