Using mvcSitemap with ASP.NET MVC 5

692 Views Asked by At

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 ?

2

There are 2 best solutions below

0
On BEST ANSWER

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()
0
On

In addition to Kartikeya Khosla's answer (which is correct), you can customize the behavior of AuthorizeAttribute, if needed, as shown in this answer. Just be sure you are using the correct NuGet package for MVC 5.