TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
jamala g
NA
34
6.5k
The ViewData item that has the key ‘Name’ is of type System
Oct 15 2019 12:21 AM
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>
Attachment:
RoleBasedAuthentication-master.zip
Reply
Answers (
5
)
Lost .sln file, decompile .aspx & .dll into equivalent .cs
How to change the _type value in elasticsearch using Nest?