Copied to clipboard

Flag this post as spam?

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


  • Jose Cera 6 posts 75 karma points
    Sep 15, 2016 @ 07:50
    Jose Cera
    0

    Redirect through controller

    I want to redirect to another view throuh its associated controller, how can I do that? what kind of controller should I use? I tried with a SurfaceController and a return view() but it redirects wrong.

  • Alex Skrypnyk 6163 posts 24143 karma points MVP 8x admin c-trib
    Sep 15, 2016 @ 17:19
    Alex Skrypnyk
    0

    Hi Jose,

    Try to use RenderControler - https://our.umbraco.org/documentation/reference/routing/custom-controllers

    What method did you use for redirect?

    Thanks,

    Alex

  • Jose Cera 6 posts 75 karma points
    Sep 15, 2016 @ 22:29
    Jose Cera
    0

    Hi Alex,

    I'm using surfacecontrollers, for some reason the Rendermvccontrollers are not working for me.

    Thanks,

    ~Jose

  • Alex Skrypnyk 6163 posts 24143 karma points MVP 8x admin c-trib
    Sep 16, 2016 @ 07:28
    Alex Skrypnyk
    0

    Jose, can you show code what trying to make redirect for you?

    Do you want to redirect to another view ? So render another view on this page is your goal?

    Or redirect to another URL?

    Thanks,

    Alex

  • Jose Cera 6 posts 75 karma points
    Sep 17, 2016 @ 20:12
    Jose Cera
    0

    Hi Alex,

    This my controller class (it only works when inherits from surfacecontroller)

    using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using Umbraco.Web.Mvc;

    namespace UmbracoTry3.Controllers { public class ReportSurfaceController : RenderMvcController { public ActionResult Index() { return View("View1"); } } }

    I tried to call the controller from the view with this line but it didnĀ“t work, redirects to http://localhost:57544/umbraco/Surface/ReportSurface and finds nothing.

    So I did this and it worked (for SurfaceController not for RenderMvcController)

            <script type="text/javascript">
                $(function(){
                    $("#btnBuscar").click(function () {
                                            window.location.replace("http://localhost:57544/Umbraco/Surface/ReportSurface/Index");
                                        });
                                    });
                </script>
    

    Thanks

Please Sign in or register to post replies

Write your reply to:

Draft