开发者

asp.net mvc 3: Page.User.IsInRole("xy") returns null

I migrated an mvc 2 app to version 3.

Unfortunatly in my partial logon file, an exception is th开发者_如何学Gorown when the user is logged in. The Request.IsAuthenticated returns true, but the Page.User returns null!

And of course

Page.User.IsInRole("xy")

throws an exception: Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: Cannot perform runtime binding on a null reference

How do I check the user role with Razor?


Found the solutions by looking at a default mvc3 project:

Context.User.IsInRole("xy")

instead of Page.User.IsInRole("xy")

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜