I am using asp.net mvc with razor. How can I hide links which are only for admins?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You could declare a boolean property on your view model:
and inside your view:
and of course inside the controller action rendering this view you would populate this view model:
Obviously the Bar action which only administrators could invoke should be decorated with the
Authorizeattribute as well: