5

I am trying to find a good walkthrough or example of how to use the new Identity authorization system with added roles. When you create a new website in VS 2013 there is also an Account folder and in the database you have the tables also connected to roles. But all examples available are connected to MVC! Does anybody have a link to a good Identity users or programmers guide that does not use MVC?

Looking forward to any proposal in this matter.

1

3 Answers 3

3

Here is an excellent step-by-step significant informative tutorial as part of asp.net/webforms learning path.

It gives thorough knowledge & details like,

  • Create/Manage Roles
  • Assigning Roles to Users
  • Role-Based Configuration

Update: Here is Asp.net Identity tutorial for web forms for empty project & existing web-forms. For roles customization, you can refer this article. Though it is in MVC 5 but it applies to asp.net web-forms as well.

Sign up to request clarification or add additional context in comments.

5 Comments

Thank you for your answer, but this tutorial uses the old Membership system of ASP.NET, not the new Identity that we got in VS 2013.
Thank you, that looks like something I can use.
Scott Allen has some nice tutorials on his blog about ASP.NET Identity. The information he provides is normally better than the ones you will find on the official site.
yes, i just checked these articles & they are promising, one should consider to refer once.
@PalakBhansali nice reference to a detailed article , which discusses stuff starting from Empty project , and that it discusses the OWIN as well..
1

I am attempting to do the same exact thing. This is the tutorial that I'm using to help accomplish creating a role using web forms.

It branches off a previous project, but it gives a download link to the previous project to build upon. Hope this helps!

The only downside is it creates a brand new user and adds it into the new role instead of assigning a current user to it.

http://www.asp.net/web-forms/overview/getting-started/getting-started-with-aspnet-45-web-forms/membership-and-administration

Comments

0

I've found an answer on another page here to add users to roles by Tarzan. Here is the code:

internal class Security
{
ApplicationDbContext context = new ApplicationDbContext();

internal void AddUserToRole(string userName, string roleName)
{
    var UserManager = new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(context));

    try
    {
        var user = UserManager.FindByName(userName);
        UserManager.AddToRole(user.Id, roleName);
        context.SaveChanges();
    }
    catch
    {
        throw;
    }
}
}

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.