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'.
this is the Code
Controller
- [AllowAnonymous]
- public ActionResult Register()
- {
- ViewBag.Name = new SelectList(_db.Roles.ToList(),"Name","Name");
- return View();
- }
View Code
- class="form-group">
- @Html.LabelFor(m => m.Name, new { @class = "col-md-2 control-label" })
class="col-md-10">- @Html.DropDownListFor(m => m.Name,ViewBag.Name as SelectList ,"--Select Role--",new { @class = "form-control" })

Gopaiah NekarukantiRank #2,077 · 695 reputationPosted Oct 14, 2019, 9:48 PM EDT
jamala g27 reputationPosted Oct 17, 2019, 8:43 AM EDT
jamala g27 reputationPosted Oct 17, 2019, 9:01 AM EDT
Gopaiah NekarukantiRank #2,077 · 695 reputationPosted Oct 18, 2019, 2:21 AM EDT
jamala g27 reputationPosted Oct 19, 2019, 12:19 AM EDT
Gopaiah Nekarukanti i have tried this But its Still Gives error will you please try to fix it in the Code I gave his link if it is not too much trouble for you