ASP.NET MVC deployment to IIS 5/6 with Virtual Directory

asp.net-mvciis

I have an asp.net MVC App that I want to deploy to IIS 5 and/or 6 using a Virtual Directory.

I have already performed the wildcard routing, but I have a problem with relative paths.

Imagine I have created a virtual directory called myApp.

After deploying I can go to http://localhost/myApp and am greeted by the index page. My index page has a link defined as <a href="/Employees">Employees</a>. Clicking on this navigates to
http://localhost/Employees which results in a 404 error.

I would like it to navigate to http://localhost/myApp/Employees instead, but I would prefer it if I didn't have to code the virtual directory name into my project.

Thanks in advance for any help.

Best Answer

Use Html.ActionLink to generate your hyperlinks rather than creating them directly, I think that'll sort it for you. Alternatively, use ./Employees which should get you where you want to go.