Copied to clipboard

Flag this post as spam?

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


  • Sonja 133 posts 621 karma points
    Jan 10, 2019 @ 07:07
    Sonja
    0

    MVC Get doesn't load

    Hi I have partial view

    @model MyProject.Models.ListParameters
    @using Umbraco.Web
    @using MyProject.Controllers
    @using Umbraco.Web.Mvc
    
    
    @using (Html.BeginUmbracoForm<ProductListController>("DisplayList", Model))
    {...}
    

    and I also have controller

     public class ProductListController : Umbraco.Web.Mvc.SurfaceController
        {
    
            [HttpGet]
             public ActionResult DisplayList(ListParameters model)
            {
    
                return PartialView(model);
            }
        }
    

    The DisplayList get method is never executed and I need it to be executed.

    Please Advice

  • Nik 1614 posts 7260 karma points MVP 7x c-trib
    Jan 10, 2019 @ 13:39
    Nik
    0

    Hi Sonja,

    The reason your MVC controller isn't being hit is probably because you've yet to put in a dedicated route for it.

    Out of the box, although MVC based, Umbraco replaces all of the routing to go through it's own routing behaviour. This makes various Umbraco things available to pages correctly.

    You might be better off looking into using an Umbraco Surface Controller to do what you are doing.

    The docs here should help you get an understanding of the routing that Umbraco does by default: https://our.umbraco.com/documentation/Implementation/Default-Routing/

    This will help explain the Umbraco Controller options: https://our.umbraco.com/documentation/Implementation/Controllers/

    And this can help you with custom routing: https://our.umbraco.com/documentation/Implementation/Custom-Routing/

    See how you get on with those but if you need more help feel free to reach out :-)

    Nik

  • Sonja 133 posts 621 karma points
    Jan 11, 2019 @ 10:42
    Sonja
    0

    Sorry Nik, I'm going to need more help. where do I specify routes? how do I know what routes to specify? Actually how do I connect the partial view with get method from a surface controller?

    Thanks, Sonja

  • Nik 1614 posts 7260 karma points MVP 7x c-trib
    Jan 11, 2019 @ 10:46
    Nik
    100

    Hi Sonja,

    No need to apologise :-)

    This video, although not exactly what you are trying to do, should give you an understanding of Surface Controllers and Forms/Data https://www.youtube.com/watch?v=3V0A1AYJbys

    The CodeShare tutorials are pretty decent so I do recommend them. It's easy to follow.

    Let me know if you are still stuck after you've had a look at the video :-)

    Nik

  • Sonja 133 posts 621 karma points
    Jan 11, 2019 @ 18:53
    Sonja
    1

    I found the answer in the video. I put @{Html.RenderAction("DisplayList", "ProductList", Model);}

Please Sign in or register to post replies

Write your reply to:

Draft