Building an application, and there will be different levels of access.
What is the recommended way to restrict the display of navigation elements to those appropriate to the current use开发者_如何学编程r? Are there any built-in helper for this?
I asked a similar question here. There are a few options, depending on your needs something as simple as checking User.Identity.IsInRole("xyz") in the view may suffice (not ideal, but it gets the job done).
If you have a complex navigation structure, the answers provided in my question maybe of use to you.
I should point out that as @casperOne has mentioned, the [Authorize]
attribute will prevent unauthorized access to the actions in question, but will not help with the display of menu navigation to them.
精彩评论