How to change root path ~/ in Razor in asp.net core

£可爱£侵袭症+ 提交于 2020-06-25 08:54:08

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!