Home Page shows no Campaigns when there are campaigns seeded
See original GitHub issuewhen loading HomeController/Index, the page is displaying with no Campaigns
looking at the view model before it’s sent back to the view, there are six campaigns that were populated from a query handler:
so we should be showing these campaigns.
Looking closer at \Home\Index.cshtml it looks like we’re using knockout to populate the list of campaigns. Checking out the errors via Chrome’s debugger, looks like knockout is throwing this error:
Not being a javascript or a knockout guy, my initial guess is knockout can’t “define” ImageUrl
b/c it’s included on each CampaignViewModel
coming back in the list of campaigns
and the ImageUrl
used on CampaignSummaryViewModel
.
which are both included on the HomePageViewModel
returned to the view.
That, or there is a problem with the version of the knockout library we’re using in conjunction with RTM? (this is also a guess).
A very simple fix for this is to not use knockout. We’re showing a simple table of data here, so MVC is the easiest way to make that happen. After a quick refactor to use MVC/razor view to show the data, the page is working again:
Should I submit a PR for this by “knocking out” 👊 the knockout code?
Issue Analytics
- State:
- Created 7 years ago
- Comments:9 (5 by maintainers)
Top GitHub Comments
+1 “to change the case used and follow the new MVC standard.” over reverting to pre rtm Json serialization behavior.
The problem seams be caused is caused by the fact that, in 1.0.0, MVC uses camel case names by default as announced here:
https://github.com/aspnet/Announcements/issues/194
the easiest change would be to change:
services.AddMvc()
toservices.AddMvc().AddJsonOptions(options => options.SerializerSettings.ContractResolver = new DefaultContractResolver());
as described by the article. But I think it would be better to change the case used and follow the new MVC standard.
These are all the views that could are probably broken because they serialize objects using the Json Helper:
Areas\Admin\Views\Event\Edit.cshtml Areas\Admin\Views\Site\EditUser.cshtml Areas\Admin\Views\Skill\Edit.cshtml Areas\Admin\Views\Task\Edit.cshtml Views\Campaign\Details.cshtml Views\Campaign\Index.cshtml Views\Campaign\Map.cshtml Views\Event_EventScripts.cshtml Views\Home\Index.cshtml Views\Manage\Index.cshtml Views\Organization\Index.cshtml Views\Organization\Organization.cshtml
I’d love to take care of it