2

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 Answers 2

1

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()
Sign up to request clarification or add additional context in comments.

Comments

1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.