Role based Authorization in MVC4 using VB.NET

Here is a simple way to do the role based Authorization in your MVC4 Controllers using VB.NET

IF you have a role called Client then simply add the following text on top of your each ActionResult( which displays the view)

<Authorize(Roles:=”Client”)>

 

See the following example. The Index View has been restricted and can only be viewed by someone in the Client role.

 <Authorize(Roles:="Client")>
        Function Index() As ActionResult
            Return View(db.Purchasers.ToList())
        End Function