Copied to clipboard

Flag this post as spam?

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


  • liran 59 posts 140 karma points
    Sep 14, 2020 @ 07:49
    liran
    0

    Umbraco 8 SurfaceController not working

    hi, i have a clean test Umbraco 8 website. i am trying to create page and SurfaceController but nothing happened. in other site (umbraco 7) it usualy work. my code: Controller:

       public class TestRedirectController : SurfaceController
    {
        // GET: TestRedirect
        [HttpPost]
        public ActionResult Index()
        {
            return View();
        }
    }
    

    Template:

    @inherits Umbraco.Web.Mvc.UmbracoViewPage
    

    @{ Layout = "master.cshtml"; }

    @Html.Action("Index", "TestRedirect")

    View:

    @{ Layout = null; }

    test redirect

  • Nik 1612 posts 7258 karma points MVP 7x c-trib
    Sep 14, 2020 @ 08:19
    Nik
    0

    Hi Iiran,

    The first thing that stands out is you are calling a Post method via Http.Action which I don't believe is possible. Try taking the [HttpPost] attribute off of your action on your controller and see if that works.

    Thanks

    Nik

  • liran 59 posts 140 karma points
    Sep 14, 2020 @ 08:29
    liran
    0

    still not working

  • Nik 1612 posts 7258 karma points MVP 7x c-trib
    Sep 14, 2020 @ 08:33
    Nik
    0

    Hi Iiran,

    What is the exact error you are getting?

    Thanks

    Nik

  • liran 59 posts 140 karma points
    Sep 14, 2020 @ 09:19
    liran
    0

    just 404, it doesn't even enter the controller. enter image description here

  • liran 59 posts 140 karma points
    Sep 14, 2020 @ 10:14
    liran
    0

    update: when i use the full link it workes: http://localhost:59216/umbraco/surface/testredirect/Index/

    but it doesn't work with template.

  • Nik 1612 posts 7258 karma points MVP 7x c-trib
    Sep 14, 2020 @ 10:44
    Nik
    100

    Ok, so it looks like this isn't a problem with your surface controller now, I'd say it's an issue with your source url.

    Because of how you've got things set up, it appears to me that you are trying to go to an existing page in the site, then when it comes to render the view for that page, hit your surface controller.

    That error tells me that either the page you are trying to go to initially doesn't exist or it has no template set against it.

    Things to check:

    1. Does a page called TestRedirect exist in your Umbraco back office, and is it's url /testredirect?
    2. Does it have a template set to be used?
  • liran 59 posts 140 karma points
    Sep 14, 2020 @ 10:51
    liran
    0

    hi Nik, i wanted to thank you for you help.

    this is what i usualy do...

    enter image description here

  • Nik 1612 posts 7258 karma points MVP 7x c-trib
    Sep 14, 2020 @ 10:56
    Nik
    0

    Hi Iiran,

    That's fine from a template point of view, but you need a doc type and a page to exist in your content tree. It's not possible to route "just" to a view which I think is what you are currently trying to do.

    What is your overall objective with this controller/Action?

  • liran 59 posts 140 karma points
    Sep 14, 2020 @ 10:59
    liran
    0

    hi, i'm doing some testing with umbraco forms. i just wanted to test receiving FormID after form has submited to another controller.

  • liran 59 posts 140 karma points
    Sep 14, 2020 @ 11:02
    liran
    1

    i got it to work, i needed the docType and create a page. thank you very much for your help.

  • Nik 1612 posts 7258 karma points MVP 7x c-trib
    Sep 14, 2020 @ 11:02
    Nik
    0

    No worries :-) Happy it's working for you.

Please Sign in or register to post replies

Write your reply to:

Draft