Reputation: 149
I did everything, as shown in the instructions: Role Based Security in ASP.NET MVC 5 Web Applications, but inside the action got the following error in Register action of AccountController:
if (result.Succeeded)
{
//Assign Role to user Here
await this.UserManager.AddToRoleAsync(user.Id, model.Name /*ERROR HERE*/);
//Ends Here
await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false);
return RedirectToAction("Index", "Home");
}
Error message:
Error 2 'HelloWorld.Models.RegisterViewModel' does not contain a definition for 'Name' and no extension method 'Name' accepting a first argument of type 'HelloWorld.Models.RegisterViewModel' could be found (are you missing a using directive or an assembly reference?)
C:\Users\IliA\Documents\Visual Studio 2013\Projects\HelloWorld\HelloWorld\HelloWorld\Controllers\AccountController.cs 163 74 HelloWorld
Upvotes: 1
Views: 1272
Reputation: 273274
At the end of step 1:
locate the RegisterViewModel class and add the following string property:
public string Name { get; set; }
Upvotes: 3