asp.net-mvc-5mvcsitemapproviderasp.net-mvc-sitemap

Using mvcSitemap with ASP.NET MVC 5


How can I integrate mvc sitemap in ASP.NET MVC application to provide Role based Access control, and is it the best why or there is a better way to have role based access ?


Solution

  • Best way to implement role based security in asp.net mvc is to use ASP.Net membership provider where u can easily use [Authorize] attribute.

    You can authorize a single actionresult as :

    [Authorize]  <--Attribute for role based security
    public ActionResult YourAction()
    {.....}
    

    You can authorize a complete Controller as :

    [Authorize]
    public class YourController : Controller
    {.....}
    

    To restrict access for specific roles, use:

    [Authorize(Roles = "Admin,Client")]
    public ActionResult YourAction()