@html.actionlink renders wrong url

149 views Asked by At

I've just started to learn ASP.NET and I'm trying to create a simple navigation but somohow i get the wrong url. I've been looking for anwsers all over the place but most are about more complex url.

I'm using this for my navigation

<nav>
        <ul>
            <li>@Html.ActionLink("Home", "index")</li>
            <li>@Html.ActionLink("Domeinen", "Domain")</li>
        </ul>
    </nav>

The website renders but when I click "domeinen" It brings me to

http://localhost:7498/Home/Domain

instead of

http://localhost:7498/Domain

Can anyone point me in the right direction?

1

There are 1 answers

0
Joanvo On BEST ANSWER

By default, it creates a url to the current controller (which is Home in your case). If you want to modify it, you can use another of this function signatures:

Html.ActionLink("Domeinen", "Domain", "DomainController")