Blazor Server应用程序使用错误的CSS文件URL
我创建了一个使用VS2022的简单的Blazor Server应用程序。我只是使用默认示例代码,没有进行任何更改。然后,该应用程序在我的服务器上运行,可以在其中通过https:// myServer/myApp访问它(IIS重定向重定向到http:// localhost:5000)。
现在的问题是该应用找不到任何CSS文件。例如,它试图加载“ https://myserver/css/site.css”,但不存在。正确的路径是“ https://myserver/myapp/css/site.css”。
如何更改大火应用程序查找其文件的路径?
I have created a simple Blazor Server app with VS2022. I just used the default example code and made no changes. The application is then run on my server, where I can access it via https://myserver/myapp (a IIS redirect redirects that to http://localhost:5000).
The problem now is that the app cannot find any of the CSS files. E.g. it tries to load "https://myserver/css/site.css", which does not exist. The correct path would be "https://myserver/myapp/css/site.css".
How can I change the path where the Blazor app looks for its files?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当您将其作为常规IIS网站安装时,它将“开箱即用”。但是随着IIS的重定向,事情可能会崩溃。
您现在最好的选择是将_layout.cshtml中的基本href更改为
When you had installed it as a regular IIS WebSite then it would have worked 'out of the box'. But with a IIS redirect things could fall apart.
Your best option now is to change the base href in _Layout.cshtml to