问题
The simplest question for which I can't find an answer.
I have an asp.net core 2.1 MVC application with Razor.
Application widely uses ~/path
syntax.
Everything works great if application runs from domain root (for example, from http://localhost:5000/)
But when I run application at non-root (for example, http://localhost:5000/app) the Razor still uses root (/
) as base path.
Question: how to configure this? How to specify base path for Razor's ~/
? There must be an environment variable for it :)
PS: Application run in docker behind the reverse proxy.
回答1:
In your "Startup" class in the "Configure" method use next:
app.UsePathBase("/yourBasePath");
来源:https://stackoverflow.com/questions/51155917/how-to-change-root-path-in-razor-in-asp-net-core