I'm having trouble just displaying a List with NancyFx. The issue seems to be something pretty basic I'm missing or perhaps the framework has changed from the examples?

My Module looks like this:

public IndexModule()
{
    Get["/"] = parameters =>
    {
        dynamic d = new BlogPost();
        return View["index", d];
    };
    Post["/"] = paramters =>
    {
        IEnumerable<BlogPost> result = new List<BlogPost>()
        {
           new BlogPost { Id = 3 },
           new BlogPost { Id = 5 }
        };
        return View["index", result];
    };
}

My cshtml:

{
         @foreach (var item in Model) 
         {
                  <tbody>
                        <tr>
                            <td>
                                @item.Id
                            </td>
                        </tr>
                  </tbody>
         }
}

Inside the .cshtml I tried each separately, they didn't work:

@inherits Nancy.ViewEngines.Razor.NancyRazorViewBase<NancyApplication.Objects.BlogPost>
@model System.Collections.Generic.IEnumerable<NancyApplication.Objects.BlogPost>

Oddly I don't get errors! I Just get a blank page with no html generated at all!

Related posts

Recent Viewed