The URL for the administration section of my website always starts with Admin/
. Is it possible in ASP.NET MVC to restrict access to users by using this part of the
You can create a BaseAdminController, having all of your Admin Controllers extend this:
[Authorize(Roles = "Administrator")]
public class BaseAdminController : Controller {
}
Now, if you want it by URL, you did it correct already, but if you are just saving yourself from making sure it's on everything, above is the way. Then, you're tests can just make sure that all controllers in the Admin namespace extend this controller.