I have the Registration
controller:
public class RegistrationController : Controller
{
private RegistrationVmBuilder _registrationVmBuilder = new RegistrationVmBuilder();
public ActionResult Index()
{
return View(_registrationVmBuilder.BuildRegistrationVm());
}
}
and the RegistrationBuilder
class:
public class RegistrationVmBuilder
{
public RegistrationVm BuildRegistrationVm()
{
RegistrationVm registrationVm = new RegistrationVm
{
Courses = GetSerializedCourseVms(),
Instructors = GetSerializedInstructors()
};
return registrationVm;
}
}
RegistrationVm
class:
public class RegistrationVm
{
public string Courses { get; set; }
public string Instructors { get; set; }
}
_Layout.cshtml:
@model string
<html ng-app="registrationModule">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js"></script>
<script src="~/Scripts/jquery-2.1.4.min.js"></script>
<script src="~/Scripts/bootstrap.js"></script>
<script src="~/Scripts/registration-module.js"></script>
@RenderSection("JavascriptInHead")
<link href="~/Content/bootstrap.min.css" rel="stylesheet" />
<link href="~/Content/bootstrap-state.min.css" rel="stylesheet" />
<title>College Registration</title>
</head>
<body>
@RenderBody()
</body>
</html>
And in index view:
@model TestApp.Models.Registration.RegistrationVm
The problem is when i run the app I got this error:
The model item passed into the dictionary is of type 'TestApp.Models.Registration.RegistrationVm', but this dictionary requires a model item of type 'System.String'.
http://localhost:30460/registration
– user2019037