Search code examples
asp.net-mvcreleasevirtual-path

My virtual path isn't working in release mode in MVC 4


My project (named Viper) seems to be working fine in debug mode on my dev PC.

The following line

<a href="@Url.Action("Index", "Setup")">Setup</a>

gives me the following link in the browser in dev, which works fine:

http://localhost/Viper/Setup

However, when I release this to the staging pc, when I look at the same link, I get this:

http://setup

Any idea why the release mode isn't capturing the virtual path?


Solution

  • why not use

    @Html.ActionLink("Setup", "Index", "Setup")
    

    if you need the relativa path you can use

    @Url.Content("~/")
    

    so in your case

    <a href="@Url.Content("~/" + Url.Action("Index","Setup"))" >Setup</a>