开发者

Testing user role , Authorize attribute in VB.NET

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 t开发者_JAVA技巧he 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.


in vb it would be:

<Authorize(Roles := "Manager")> _
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜