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" })
jamala gPosted Oct 19, 2019, 4:19 AM
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
Gopaiah NekarukantiPosted Oct 18, 2019, 6:21 AM
jamala gPosted Oct 17, 2019, 1:01 PM
jamala gPosted Oct 17, 2019, 12:43 PM
Gopaiah NekarukantiPosted Oct 15, 2019, 1:48 AM