samedi 27 juin 2015

Debugging & Determining Cause of View Render Error

I have inherited an ASP .NET MVC website that uses Nancy. I am new to using Nancy so this is all a bit foreign to me. The login page is a simple HTML page (not sure why but the previous developer chose this). Once logged in we are redirected to the view Steader/index.cshtml.

Every time I login and get redirected to the next view Steader/index.cshtml my server outputs an error suggesting that the model or one of its properties is null.

Has anyone experienced such an error before or can suggest what the cause may be? I've posted below; the error that occurs and the view cshtml file.

Any advice would be greatly appreciated.

[14:35:00.7132](ERROR) Unable to render the view.  Most likely the Model, or a property on the Model, is null
   at Nancy.ViewEngines.Razor.NancyRazorViewBase`1.ExecuteView(String body, IDictionary`2 sectionContents)
   at CallSite.Target(Closure , CallSite , Object , Object , Object )
   at System.Dynamic.UpdateDelegates.UpdateAndExecuteVoid3[T0,T1,T2](CallSite site, T0 arg0, T1 arg1, T2 arg2)
   at Nancy.ViewEngines.Razor.RazorViewEngine.<>c__DisplayClass27.<RenderView>b__26(Stream stream)
   at Nancy.Responses.MaterialisingResponse.PreExecute(NancyContext context)

Steader/index.cshtml:

@inherits Nancy.ViewEngines.Razor.NancyRazorViewBase<dynamic>
@{
    Layout = "layouts/main.cshtml";
    Bundles.Reference("Scripts/Steader/Steader.js");
}
<div class="row action-data">
@foreach (var action in @Model) {
  <div class="col-xs-12 col-md-4 action-item"><a href="#" data-toggle="modal" data-action="@action.Id" data-target="#viewActionModal">@action.Name</a></div>
 }
</div>

Aucun commentaire:

Enregistrer un commentaire