I migrated an mvc 2 app to version 3.
Unfortunatly in my partial logon file, an exception is thrown 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")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With