> For the complete documentation index, see [llms.txt](https://jen-hsuan-hsieh.gitbook.io/asp-net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jen-hsuan-hsieh.gitbook.io/asp-net/chapter1/1.1.the-complete-asp.net-mvc-5-course/18authentication-and-authorization/185working-with-roles.md).

# 1.8.5.Working with Roles

* 1.Add RoleName.cs

  ```
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;

    namespace Vidly2.Models
    {
        public class RoleName
        {
            public const string CanManageMovie = "CanManageMovie";
        }
    }
  ```
* 2.Modify the movieController.cs

  ```
        public ActionResult Index()
        {
            if (User.IsInRole(RoleName.CanManageMovie))
            {
                return View("List");
            }
            return View("ReadOnlyList");
        }
        [Authorize(Roles = RoleName.CanManageMovie)]
        public ActionResult New()
        {
            var genreTypes = _context.genreType.ToList();
            var viewModel = new MovieFormViewModel
            {
                genreTypes = genreTypes
            };
            return View("MovieForm", viewModel);
        }
  ```
* 3.Rename Movie/index.cshtml to list.cshtml
* 4.Add a new file: ReadOnlyList.cshtml
