I agree with the use of a base view model, or perhaps just with an interface like CanEdit. If you are walking through the interface, you can set the property in ActionFilter in the OnActionExecuted method.
To bind it to a view, creating a new HtmlHelper would be pretty simple. I would use TextBoxFor as the base class, since it has access to the view model. Then you can check the property and create the necessary HTML attribute. However, after going through this route, you will need to create a new helper for each type of input control you need (text box, selection list, etc.).
Without all the details about what you are doing, a much simpler idea would be to not provide the "Save" button for read-only users. The Save button will be controlled by one property in the view model (or ViewData, if you want).
Several other people mentioned that server-side restriction is still necessary so that people do not bypass client restrictions. To do this, you will need an action filter. This link has a good idea about this.
source share