Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at

  • MBE 245 posts 846 karma points
    Feb 02, 2021 @ 15:21

    Modelbuilder and namespace

    Hi (Matt), ;)

    I've been digging around the demo store and noticed that you use code that doesn't exactly work on my machine so I'm wondering what I'm missing. I have a feeling it might be related to which modelbuilder is used?


    On the home page you use: @Html.Action("FeaturedProducts", "ProductSurface") which returns the following error:

    No route in the route table matches the supplied values.

    You also seem to use the following on the search page where you use the namespace @using Vendr.DemoStore;

    @using Vendr.DemoStore; 
    @Html.Partial("Pagination",  Model.Cast<IPublishedContent, object>())

    Which returns:

    CS1061: 'PagedResult<IPublishedContent>' does not contain a definition for 'Cast' and no accessible extension method 'Cast' accepting a first argument of type 'PagedResult<IPublishedContent>' could be found (are you missing a using directive or an assembly reference?)

    Since I don't use the Vendr.DemoStore I'm wondering if it's possible to see what's inside that namespace?

    // Mike

  • Tom Madden 244 posts 399 karma points MVP c-trib
    Feb 02, 2021 @ 16:32
    Tom Madden

    Hi Mike, the demo store is open source on Github,



  • Matt Brailsford 3020 posts 15702 karma points MVP 7x c-trib
    Feb 03, 2021 @ 09:22
    Matt Brailsford

    Hi Mike,

    I don't think this is a ModelsBuilder issue, I just think you have missed copying some bits over.

    The first code snippet is attempting to render a child action, but given the error, it would appear you haven't copied over our ProductSurfaceController which is responsible for rendering the featured products

    Regarding the second issue, again, it looks like you've not copied over the Cast extension method which you can find here

    Hope this helps


    PS As Tom said, the whole of the demo store is open source so you can review all the code for it at

  • MBE 245 posts 846 karma points
    15 days ago

    Hi Matt,

    You are right, I don't have those files in the Vendr.DemoStore folder. If I download that entire folder, where should I place it?

    I can see your DEMO project's .SLN file refers to the two folders:

    • src\Vendr.DemoStore\Vendr.DemoStore.csproj
    • src\Vendr.DemoStore.Web\Vendr.DemoStore.Web.csproj

    Which mine doesn't. If I dowload the entire Vendr.DemoStore folder, how do I refer to it?

  • Bjarne Fyrstenborg 1188 posts 3449 karma points MVP 4x c-trib
    Feb 03, 2021 @ 10:39
    Bjarne Fyrstenborg

    Hi Mike

    When using ModelsBuilder you should be aware of these settings in Web.config:

    With these settings in demo store, ModelsBuilder generates the classes in this folder and use the namespace Vendr.DemoStore.Models:

    With this approach also ensure that new generated models are included in the project and compiled in the assembly, when building the project/solution.


Please Sign in or register to post replies

Write your reply to: