c# – Multiple authentication types


In my system I need to have two types of authentication one for a common User who will register and etc. and another for the administrator my question is how do I differentiate the two authentications using FormsAuthentication, I believe there will be some conflict for example when I save the values ​​in:

FormsAuthentication.SetAuthCookie(user.UserName, model.RememberMe);

I looked for some examples on Google but I didn't have much success! I understood more or less that it would be necessary to create different rules.

Anything will be welcome! examples, links, articles…


As per your question, you are already using ASP.NET Form Authentication.

To implement different roles for your users (Administrator, User), you can use Membership Roles.

For example:

public ViewResult Edit(int id)
    return View("Edit");

You can check if the user is in a role group like this:

if (User.IsInRole("Administrator"))

To use Membership Roles, after you create a Web Application in Visual Studio, enter the ASP.NET configuration site and add the roles according to your application.

A good tutorial can be found on the ASP.NET website:


An example application that uses these frameworks is the MVC Music Store, found at:


Scroll to Top