I created a controller called Employeecontroller with the following function:
Function Details() As ActionResult
Dim myemployee As New Employee
myemployee.Name = "John"
Return View()
End Function
After that I "Add a View" with the following settings:
View name: Details
Template: Empty
Model class
Employee(ProjeytName.Models)
According to this solution a strongley typed view is generated. My View Code looks like:
@ModelType MVC_AdminTry1.Models.Employee
@Code
ViewData("Title") = "Employee Details"
End Code
<h2>@Model.Name</h2>
Now I get a Null Reference Error pointing to @Model.Name but I just cannot see, what is wrong. Could anyone help me here?
You need to send the model to the View:
Return View(myemployee)