I have an mvc3 web application with entity framework 4.1. I’ve created two roles – users and administrators. When I log into my application as an administrator, I want to see the Delete links next to records in the table. However, if a user logs in, I only want them to see Edit and Details and not Delete.
What’s the best way to do this?
I have an mvc3 web application with entity framework 4.1. I’ve created two roles
Share
This is a mixed bag with multiple answers. There are two great ways to do it.
One is to create all the links in a controller (or Global Application_Request) based on the logged in user and pass it to the view. I’m not a fan of this because links being created by the controller are in my opinion, the responsibility of the view.
The second way is to manually check in the view itself. It’s simple it’s clean but it is logic in a view.
Partial-Menu.cshtml