server.mappath在MVC应用程序中,带有大华
我有一个MVC 6.0应用程序,没有启动。我需要在我的一个大型组件中获取server.mappath。 Blazor的代码没有构造函数,因此我无法注入其中。
原因是我的数据文件夹中有一个字体文件,需要将其转换为流,以便我的PDF生成器可以使用它。我似乎无法找到该文件的途径。
有什么想法吗? 谢谢你!
I've got a MVC 6.0 app, without startup.cs, that I've added Blazor to. I need to get Server.MapPath inside one of my Blazor components. The Blazor's code doesn't have a constructor so I can't inject into it.
The reason is i've got a font file in my Data folder that I need to turn into a stream so my pdf generator can use it. I can't seem to get a path to that file.
Any thoughts?
Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我的解决方案是将
iwebhostenvironment
env注入我的Blazor Server页面。在代码范围的部分类中,我添加了:这使我可以访问
ContentRootPath
。My solution was to inject
IWebHostEnvironment
env into my Blazor Server page. In the code-behind partial class I added:This gave me access to the
ContentRootPath
.