I can't find out how to solve this. I have two URLs. These are /my-url-1
and /my-url-2
. Both going to different views.
The thing is that I have an ActionLink on /my-url-1
's view which should make /my-url-2
and go to that view.
The problem is that ActionLink makes /my-url-1/my-url-2
as the URL and not just /my-url-2
.
I was searching two days about how to fix it but couldn't find anything.
PD: I'm not using Areas so please don't tell me that I just should put the "area" parameter as a "".
These are two urls which goes to different controllers and different actions.
View which has the ActionLink (URL:/my-url-1
) :
<div class="btn-index-container">
@Html.ActionLink("Url 2", "MyAction", "MyController")
</div>
This ActionLink should render:
<a href="/my-url-2">Url 2</a>
But it's rendering:
<a href="/my-url-1/my-url-2">Url 2</a>
where /my-url-1
is my current URL
Route Config
routes.MapRoute(
name: "route1",
url: "my-url-2", //without parameters
defaults: new { controller = "MyController", action = "MyAction" },
);
routes.MapRoute(
name: "route2",
url: "my-url-1", //without parameters too
defaults: new { controller = "MyController2", action = "MyAction2" }
);
So, when I go to localhost:port/my-url-1
it loads MyAction2
which renders a view. This view has inside an ActionLink
(described above) which should render a /my-url-2
link.