Authorize
attribute on controllers and/or actions to specify which users and/or roles can invoke them, e.g. [Authorize(Users = "Betty, Johnny")]
public ActionResult SpecificUserOnly()
{
return View();
}
[Authorize(Roles = "Admin, Super User")]
public ActionResult AdministratorsOnly()
{
return View();
}
Dear Gentle,You mention MVC in the title but Web Forms in the post. We need to know which it is in order to provide appropriate advice. I haven't used Web Forms in a long time - I recommend that you don't either - so I don't really know what the security protocols are there. In an MVC app, if you are using Microsoft Identity, which is built into ASP.NET, then you use theAuthorize
attribute on controllers and/or actions to specify which users and/or roles can invoke them, e.g.
That's C# code pilfered from elsewhere but it's the same attribute in VB.C#:[Authorize(Users = "Betty, Johnny")] public ActionResult SpecificUserOnly() { return View(); } [Authorize(Roles = "Admin, Super User")] public ActionResult AdministratorsOnly() { return View(); }
You mention MVC in the title but Web Forms in the post. We need to know which it is in order to provide appropriate advice. I haven't used Web Forms in a long time - I recommend that you don't either - so I don't really know what the security protocols are there. In an MVC app, if you are using Microsoft Identity, which is built into ASP.NET, then you use theAuthorize
attribute on controllers and/or actions to specify which users and/or roles can invoke them, e.g.
That's C# code pilfered from elsewhere but it's the same attribute in VB.C#:[Authorize(Users = "Betty, Johnny")] public ActionResult SpecificUserOnly() { return View(); } [Authorize(Roles = "Admin, Super User")] public ActionResult AdministratorsOnly() { return View(); }