I'm wondering how it is possible to run an MVC application in a subdirectory. The problem is that when running in a subdirectory, every Action seems to be navigated to the Root path rather then the subdirectory.
In order to test if it would work, I've edited the "Project URL" and "Override application root URL" in the project properties window.
I've considered adding a key to the web.config with the configurable routing value and creating a singleton class that would read this key, although i would have to manually editing all pages to make it work, but clearly that wouldn't be the best way out there as it would take a lot of time and when willing to change the directory name, you'd have to change it over all the pages in the application.
Another thing I tried is editing the RouteConfig.cs file and replacing / adding it along with the default router.
routes.MapRoute(
name: "Rooted",
url: "{root}/{controller}/{action}/{id}",
defaults:
new { root = "Admin", controller = "Login", action = "Index", id = UrlParameter.Optional }
);
Sadly this however didn't seem to work either as it would still redirect to Index/Home instead of Admin/Index/Home.
I'm wondering if someone has a better idea how to get this to work with as little change as possible. I can't be the first one to ask this, and when Googling about possible duplicates none came up with a suitable solution.
Turned out my problem was caused by something entirely different.
It went to the rootfolder because the form submit contained a hard path aka "/login/login" instead of "~/login/login".
Even though it was not the answer, I suggest people to look at faby's post too as it does contain some nice information which shouldn't get lost.