Reputation: 268
I've created this route: Home / PaginaBase.
This route is called a new page, called PaginaBase, which has a similar header and footer Index. This creates a footer menu.
When I select an item from this menu, he calls me PaginaBase riding a URL like this:
http://www.localhost:58686/Home/PaginaBase/6/3.
Until then, it's ok. When I select another item (PaginaBase still inside), it retains the same URL in the call and adds Home/PaginaBase/8/3
again, there is a non-existent route.
How do I solve this?
Below is 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) {
}
});
}
Upvotes: 2
Views: 38
Reputation: 22007
You're using relative URLs in your links. If you're in /Home/PaginaBase/6/3
(i.e. that's 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
.
Using absolute URLs will replace your path instead of appending to it: /Home/PaginaBase/8/3
(notice the /
in the beginning).
Upvotes: 1