Copied to clipboard

Flag this post as spam?

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


  • Rob Carlaw 21 posts 134 karma points
    Apr 28, 2017 @ 13:52
    Rob Carlaw
    0

    Surface controller can't find view

    Hi,

    I've created a surfacecontroller like: [PluginController("mypluginapp")] public class CartController : SurfaceController { [ChildActionOnly] public ActionResult AddToCart( int id) { AddToCartViewModel vm = new AddToCartViewModel(); vm.Name = "blahhhhh"; return PartialView(vm); }

    In my top level view I'm calling the action like:

    @Html.Action("AddToCart", "Cart", new {id = 1234})
    

    I get the error on the Html.Action that it can't find the view - it should be loading:

    ~/App_Plugins/mypluginapp/Views/Cart/AddToCart.cshtml

    The actual error is:

    The partial view 'AddToCart' was not found or no view engine supports the searched locations. The following locations were searched:

    ~/Views/Cart/AddToCart.aspx

    ~/Views/Cart/AddToCart.ascx ....

    It looks like it's not searching in ~/app_plugin/..

    I'm using version 7.6.0.0

  • Alex Skrypnyk 6175 posts 24186 karma points MVP 8x admin c-trib
    Apr 28, 2017 @ 14:11
    Alex Skrypnyk
    1

    Hi Rob

    Did you try to define full path to partial?

    return PartialView("~/App_Plugins/mypluginapp/Views/Cart/AddToCart.cshtml", vm);
    

    Thanks,

    Alex

  • Rob Carlaw 21 posts 134 karma points
    Apr 28, 2017 @ 14:44
    Rob Carlaw
    0

    Hi,

    Yes that worked!

    Would be better without the path and the viewengine picking it up.

    Thanks for helping out!

    Thanks

    Rob

Please Sign in or register to post replies

Write your reply to:

Draft