Running an ASP.NET MVC application in a subdirectory, getting 404 errors

I have an application using ASP.NET MVC. I deployed it to the Crystal Tech server (hence direct access to the IIS control panel).

It was originally run in the root directory, and everything was fine. Then the client decided that he should work in a subdirectory. I moved the application there and the home index page appeared, but every other page tries to access the controller / action / page / view in the original root directory. I do not understand this, since the links were all contextual (for example, using .. / controller / action as opposed to mysite.com/controller/action).

Am I doing something wrong here? What are my options?

Thanks James

+1
source share
1 answer

I would use UrlHelper to create links. This ensures that they relate to the application path.

<a href="<%= Url.Action( "action", "controller" ) %>">Link Text</a>

and

<img src="<%= Url.Content( "~/images/myimg.jpg" ) %>" alt="My Image" />
+2
source

Source: https://habr.com/ru/post/1729273/


All Articles