How to change running route?

1

Use MVC5 and Visual Studio 2013. I created this route: Home/PaginaBase . This route calls a new page, called PaginaBase , which has header and footer similar to Index . This footer creates a Menu. When I select an item from this menu, it calls me PaginaBase , setting up the URL like this:

  

link .

Until then, okay. When I select another item (I continue within PaginaBase ), it keeps the same URL in the call and adds Home/PaginaBase/8/3 again, so there is a nonexistent route. How do I resolve this?

Below my jquery function

function MontaMenuInferior() {

    var str = "";
    $.ajax({
        url: '/Home/MontaMenuInferior',
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        type: "POST",
        success: function (data) {

            $(data.resultado).each(function () {

                str = str + '<ul class="grid_4">' +
                                    '<li>' + this.SubCategoria + '</li>';


                $(this.subconsulta).each(function () {

                    if (this.Id_SubCategoria2 != null) 

                        str = str + '<li><a href="Home/PaginaBase/' + this.Id_SubCategoria2 + '/3" title="">' + this.SubCategoria2 + '</a></li>';
                        //str = str + '<li><a href="@Url.RouteUrl(PaginaBase"',new{ Parametro : this.Id_SubCategoria2, tipo : '3'} + ")">this.SubCategoria2 + '</a>'
                    else
                        str = str + '<li><a href="#' + this.SubCategoria2 + '" title="">' + this.SubCategoria2 + '</a></li>';

                });

                str = str + '</ul>';

                $('#menufooter').append(str);

                str = "";

            });
        },
        error: function (error) {

        }
    });
}
    
asked by anonymous 10.03.2014 / 13:31

1 answer

1

You are using relative URLs in your links. If you are in /Home/PaginaBase/6/3 (ie this is your path ) and you click a link to Home/PaginaBase/8/3 your new path will be /Home/PaginaBase/6/3/Home/PaginaBase/8/3 .

If you use relative URLs it will replace your path instead of concatenating it: /Home/PaginaBase/8/3 (note / at start)

  

P.S. Please this answer at your question in SOEN before reading your comment saying that you had already found the problem .

    
23.05.2017 / 14:37