2

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 Answer 1

9

in vb it would be:

<Authorize(Roles := "Manager")> _
Sign up to request clarification or add additional context in comments.

4 Comments

Thanks. Can I define some where to redirect the unauthorized user to a particular view?
@fireBand: Did you ever find an answer to the redirect question?
I'm going to try and find an answer (as I am looking too) to help the next person...
asp.net/web-forms/tutorials/security/membership/… will redirect to another page if the access level is denied.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.