c# - Role based controller access -
I am a new ASP.NET and asp.net MVC to show a user a page based on my role I am trying.
Public Class Home Controller: [Controller {[Author (roles = "reviewer")] Public Action Index () {ViewBag. Title = "revivor"; See Return (); } [Author (roles = "user")) Public Performance Index () {Return View (); }} My code is up, it gives the correct meaning that it will not compile in such a way that I can not cave two extraordinary methods with the same name. But someone can point me in the right direction
if they There should be different actions, then it makes more sense to give them names according to the role, such as: Public Sector Home Controller: Controller {[Authorized (Roles = "Reviewer ")] Public Career Reviewer () {ViewBag.Title =" Reviewer "; See Return (); } [Authorized (roles = "user")) Public action user () {return view (); }} If you can get them as one, then you can:
Public Class Home Controller: Controller { Authorized (roles = "reviewer", "user")] Public ActionRashult Index () {if (user.inincoll ("reviewer")) {look back ("reviewer"); } And {return view ("user"); }}}
Comments
Post a Comment