Leonardo
Leonardo

Reputation: 291

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 ?

Upvotes: 2

Views: 704

Answers (2)

NightOwl888
NightOwl888

Reputation: 56859

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.

Upvotes: 1

Kartikeya Khosla
Kartikeya Khosla

Reputation: 18873

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

Upvotes: 1

Related Questions