asp.net mvc : can i write AuthorizeAttribute in model
in asp.net MVC architecture, can i write AuthorizeAttribute on the method of model class?
i am trying 开发者_开发百科to do this but its not working.
please let me know how can i do this..?
No, you can apply authorization to controller's actions only.
You should check there if the user can access the actions performed on the model and then do it. Putting authorization on the model is not good, because the same model may be used in different actions, and the user may be authorized to some, and denied some other.
精彩评论