John John
John John

Reputation: 1

The new Asp.net Identity MVC 5 , can my old asp.net mvc 4 code still work

I have created a full module for managing Roles & Users inside asp.net mvc 4, for example the following action method will create a new Role:-

[HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult CreateRole(MyRole mr)
        {

            if (Roles.RoleExists(mr.RoleName) || (String.IsNullOrEmpty(mr.RoleName)))
            {

                ModelState.AddModelError(string.Empty, "Role already there!!!");

                return View(mr);

            }
            else
            {

                Roles.CreateRole(mr.RoleName);

                return RedirectToAction("Index");
            }

        }

Now i am planning to upgrade my project to use asp.net MVC 5 , and also i will be working on a new asp.net mvc5 web project. and i checked the new membership classes used inside the asp.net mvc 5 , which seems to use a new RoleManager. so does this mean that my old code for managing Roles will no longer work on asp.net mvc 5 , since it uses a new membership module ? Thanks

Upvotes: 0

Views: 158

Answers (1)

Mohsen Esmailpour
Mohsen Esmailpour

Reputation: 11554

It depend on Membership system which you are using. if you are using ASP.NET Membership, code still works and if you are going to use ASP.NET Identity, code no longer works.

Upvotes: 1

Related Questions