views:

41

answers:

1

Hi, I am using ASP.NET MVC to build a site. I am using VB as programming language.I have couple of questions.

1 I have created a role "Manager". How Do I check if a user belongs to this particular role?

For now I am using

If My.User.IsInRole("Manager") Then

'Direct to a view
Else
'Direct to another view
End If

Is this the right way?

2 How to use the Authorize attribute to limit access to a Function?

I know in C# it goes [Authorize (Roles ="Manager")] but not sure in VB.

Also can I define property to redirect a user who does not have "Manager" role to a particular view when trying to access this function .

Thanks in advance.

+1  A: 

in vb it would be:

<Authorize(Roles := "Manager")> _
BenB
Thanks. Can I define some where to redirect the unauthorized user to a particular view?
fireBand