I may be asking a question that a lot of programmers might have asked but still here it goes..
I have the a model User with following properties
public string firstName { get; set; }
public string lastName { get; set; }
public string userName { get; set; }
public int userTypeID { get; set; }
public string email { get; set; }
public long phoneNumber1 { get; set; }
public long phoneNumber2 { get; set; }
public string address { get; set; }
In the model
UserProfile() I load an object named user with a user's details as shown above and send it to the view as
View(user);
And I have created a strongly typed view as
@model OnlineShoppingSystemMVC.Models.User
@{
ViewBag.Title = "UserProfile";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<h2>UserProfile</h2>
<fieldset>
<legend>User</legend>
<div class="display-label">
@Html.DisplayNameFor(model => model.firstName)
</div>
<div class="display-field">
@Html.DisplayFor(model => model.firstName)
</div>
.
.
</fieldset>
<p>
@Html.ActionLink("Edit", "Edit", new { /* id=Model.PrimaryKey */ }) |
@Html.ActionLink("Back to List", "Index")
</p>
When I execute the application and redirect to the view it showing the following error
The model item passed into the dictionary is of type 'OnlineShoppingSystemMVC.Models.User', but this dictionary requires a model item of type 'OnlineShoppingSystemMVC.Models.Repository'.
Can any one help out on where I went wrong?
Thanks for any support in advance.