Copied to clipboard

Flag this post as spam?

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


  • Sonja 81 posts 404 karma points
    7 days ago
    Sonja
    0

    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 935 posts 3743 karma points MVP c-trib
    6 days ago
    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 81 posts 404 karma points
    6 days ago
    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 935 posts 3743 karma points MVP c-trib
    5 days ago
    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 81 posts 404 karma points
    5 days ago
    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