partial view c# mvc -
which folder should partial view can recognize @model
?
i have main index page, once person searches keyword, have viewmodel filters db results , pass partial view below:
below partialview.cshtml search results under "shared" folder.
@model namespace.viewmodels.itemviewmodel //<-------------this not been recognized, @model not exist in current context @if (model.searchresults.count == 0) { <h3 class="text-error">no items matched search query!</h3> } else { foreach (var result in model.newslist) { // display search results } }
you working on mvc4 or earlier project using visual studio 2015. unfortunately, vs2015 not provide correct parsing pre-mvc5 projects , falsely reports error.
the page still work @ runtime.
the solutions aware of use earlier version of visual studio or upgrade project mvc5.
Comments
Post a Comment