gpt4 book ai didi

css - 404 用于 Azure 上的自定义 ttf 字体 (.NET MVC 5)

转载 作者:行者123 更新时间:2023-12-03 04:22:17 25 4
gpt4 key购买 nike

我有一个问题,我之前已经看到过答案。我实现了解决方案,但问题仍然存在。

我下载了两种自定义 ttf 字体以在我的元素 Monterey 和 Bakery 中使用。

两种字体均已安装。两个前端都在我的内容文件夹中。我已经更新了两者的字体属性,以便内容在构建时复制“如果较新”。我在网络配置文件中添加了必要的语言。我在 CSS 中创建字体规则。

在我的本地计算机上,即使访问我的应用程序的 AzureSites 版本,也会显示自定义字体。在其他所有计算机上,它们不会出现并在控制台中显示 404。

请看下面的图片。先谢谢您的帮助!

This first image is how the site SHOULD look with the fonts working properly

Font files in my Solution Explorer

Relevant code in my web.config

Font properties, confirming that I am copying to the server directory

404 error messages in the console

已编辑以添加 CSS 文件的图像。

Here is the solution explorer in full. The relevant font CSS is in Site.css

Here are the font face rules in Site.css for the custom fonts.

Here is an example of the implementation of the new font-face, within Site.css

最佳答案

我怀疑问题出在 ..\fonts/baker.ttf 中的 ..

假设您的目录结构是

content/
styles/
stylesheet.css
fonts/
baker.ttf

所以当你的 html 包含

<link rel="stylesheet" href="/content/styles/stylesheet.css"/>

解析后的网址是/content/styles/../fonts/baker.ttf,一切都很好。

但是在部署 mvc 时,您的样式表可能会使用 bundler 进行捆绑和编译。该链接可能类似​​于

<link href="/bundles/css?v=Mny4y0TdpT_Ey6yWlayc6zrqhuQE-XSEh-dK8IJOsqc1" rel="stylesheet">

所以解析后的网址是 /bundles/../fonts/baker.ttf ,它不存在。我无法从屏幕截图中看出情况是否如此,但这是我的猜测。

尝试使用绝对 URL(例如 /content/fonts/baker.ttf)进行字体导入,而不是使用相对 URL。

此外,该反斜杠非常可疑。使用正斜杠,反斜杠不是网址中的有效分隔符。

关于css - 404 用于 Azure 上的自定义 ttf 字体 (.NET MVC 5),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47613046/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com