I have a brand new project in VS 2012 - MVC 4. I am not sure why I get an error that says “Object reference not set to an instance of an object.” when tryign to access the Model.Message field.
Can anyone see what I have set incorrectly?
Model:
public class MainVewModel
{
public string Message { get; set; }
}
Controller:
public ActionResult Index()
{
MainVewModel model = new MainVewModel();
model.Message = "Message Text";
return View();
}
VIew:
@using Home.Models;
@model Home.Models.MainVewModel
@section featured {
<section class="featured">
<div class="content-wrapper">
<hgroup class="title">
<h2>@Model.Message</h2>
</hgroup>
</div>
</section>
}
The error happens on