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")
精彩评论