asp.net 核心 2.0 未获取 css 或查看页面的确切路径

asp.net core 2.0 not getting exact path of css or view page

net core 2.0 我在获取完整路径时遇到了问题,如下所示如果您有任何想法请给我解决方案

 string filePath = Path.Combine(Path.Combine(Path.Combine(Path.Combine(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Plugins"), "Demopath"), "Views"), "DemoViews"), "Views.cshtml");

由此我得到了这条路

D:\ILYAS\nop4.0\Presentation\Nop.Web\bin\Debug\net461\Plugins\Demopath\Views\DemoViews\Views.cshtml

但我不需要\bin\Debug\net461\

因为这条额外的线,我没有得到我的 CSS 和查看页面 有谁知道请告诉我

提前谢谢你

路径似乎组合得当。 查看路径

Plugins\Demopath\Views\DemoViews\Views.cshtml

好像合并好了

您的问题在 AppDomain.CurrentDomain.BaseDirectory

您可以使用存储 url 而不是 BaseDirectory 或其他东西。

或者你可以去根目录Nop.Web

或使用直接路径 Server.MapPath("YourPath")

Server.MapPath好用多次Path.Combine.

用这个

Path.Combine(Environment.CurrentDirectory.ToString(), "Plugins", "MyDemo", "Content", "css", "style.css");

它会起作用