admin管理员组文章数量:1023738
I need to use specific Font in ASP.NET Core MVC Project, So, in css file:
CSS:
@font-face {
font-family: "CustomFont";
src: url(css/Custom-VariableFont_slnt.ttf);
}
But I get error that the font path is invalid
I tried to change it like:
url(~/Custom-VariableFont_slnt.ttf);
or
url(https://localhost:7267/css/Custom-VariableFont_slnt.ttf);
or
url(../css/Custom-VariableFont_slnt.ttf);
But always I get the same error:
Failed to load resource: the server responded with a status of 404 ()
I need to use specific Font in ASP.NET Core MVC Project, So, in css file:
CSS:
@font-face {
font-family: "CustomFont";
src: url(css/Custom-VariableFont_slnt.ttf);
}
But I get error that the font path is invalid
I tried to change it like:
url(~/Custom-VariableFont_slnt.ttf);
or
url(https://localhost:7267/css/Custom-VariableFont_slnt.ttf);
or
url(../css/Custom-VariableFont_slnt.ttf);
But always I get the same error:
Failed to load resource: the server responded with a status of 404 ()
Share
Improve this question
edited Nov 19, 2024 at 2:25
MrMustafa022
asked Nov 18, 2024 at 22:13
MrMustafa022MrMustafa022
255 bronze badges
1
- Would I know please why my post is downvoted, to avoid this in my coming posts? or How could I know the reason of post downvote? – MrMustafa022 Commented Nov 23, 2024 at 14:49
1 Answer
Reset to default 0Firstly you need confirm the following things:
Ensure that your font file (Custom-VariableFont_slnt.ttf) is located in the
wwwroot/css
folder.Ensure your
Startup.cs
orProgram.cs
(for .NET 6/7/8) is configured to serve static files:app.UseStaticFiles(); //be sure the middleware order app.UseRouting(); app.UseAuthorization(); app.MapControllerRoute( name: "default", pattern: "{controller=Home}/{action=Index}/{id?}"); app.Run();
Then, the wwwroot
folder is the root for static files, the path should be relative to it by using /css/Custom-VariableFont_slnt.ttf
:
@font-face {
font-family: "CustomFont";
src: url(/css/Custom-VariableFont_slnt.ttf);
}
I need to use specific Font in ASP.NET Core MVC Project, So, in css file:
CSS:
@font-face {
font-family: "CustomFont";
src: url(css/Custom-VariableFont_slnt.ttf);
}
But I get error that the font path is invalid
I tried to change it like:
url(~/Custom-VariableFont_slnt.ttf);
or
url(https://localhost:7267/css/Custom-VariableFont_slnt.ttf);
or
url(../css/Custom-VariableFont_slnt.ttf);
But always I get the same error:
Failed to load resource: the server responded with a status of 404 ()
I need to use specific Font in ASP.NET Core MVC Project, So, in css file:
CSS:
@font-face {
font-family: "CustomFont";
src: url(css/Custom-VariableFont_slnt.ttf);
}
But I get error that the font path is invalid
I tried to change it like:
url(~/Custom-VariableFont_slnt.ttf);
or
url(https://localhost:7267/css/Custom-VariableFont_slnt.ttf);
or
url(../css/Custom-VariableFont_slnt.ttf);
But always I get the same error:
Failed to load resource: the server responded with a status of 404 ()
Share
Improve this question
edited Nov 19, 2024 at 2:25
MrMustafa022
asked Nov 18, 2024 at 22:13
MrMustafa022MrMustafa022
255 bronze badges
1
- Would I know please why my post is downvoted, to avoid this in my coming posts? or How could I know the reason of post downvote? – MrMustafa022 Commented Nov 23, 2024 at 14:49
1 Answer
Reset to default 0Firstly you need confirm the following things:
Ensure that your font file (Custom-VariableFont_slnt.ttf) is located in the
wwwroot/css
folder.Ensure your
Startup.cs
orProgram.cs
(for .NET 6/7/8) is configured to serve static files:app.UseStaticFiles(); //be sure the middleware order app.UseRouting(); app.UseAuthorization(); app.MapControllerRoute( name: "default", pattern: "{controller=Home}/{action=Index}/{id?}"); app.Run();
Then, the wwwroot
folder is the root for static files, the path should be relative to it by using /css/Custom-VariableFont_slnt.ttf
:
@font-face {
font-family: "CustomFont";
src: url(/css/Custom-VariableFont_slnt.ttf);
}
本文标签: javascriptFont Path is invalid in fontfaceStack Overflow
版权声明:本文标题:javascript - Font Path is invalid in font-face - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745590984a2157884.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论