I'm new to asp mvc and Developing a Web Application in which i have told to create Roles I am using Identity framework The Error Is Given Dont Know What to with That
The ViewData item that has the key 'Name' is of type 'System.String' but must be of type 'IEnumerable<SelectListItem>'.
this is the Code
Controller
- [AllowAnonymous]
- public ActionResult Register()
- {
- ViewBag.Name = new SelectList(_db.Roles.ToList(),"Name","Name");
- return View();
- }
View Code
- <div class="form-group">
- @Html.LabelFor(m => m.Name, new { @class = "col-md-2 control-label" })
- <div class="col-md-10">
- @Html.DropDownListFor(m => m.Name,ViewBag.Name as SelectList ,"--Select Role--",new { @class = "form-control" })
- </div>
- </div>