I'm building a web application using ASP.NET Core. For font styling I used the Google Fonts API. I included some code in the head section of the _layout.cshtml file.
Locally the API is working perfectly, I know this because I tried fonts which are not installed on my machine. However when I publish my app to Hosting website, the default font is rendered
How can I solve this issue?
This is what I've tried
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Cairo:[email protected]&display=swap" rel="stylesheet">
<style type="text/css">
body {
font-family: "Cairo", sans-serif;
}
</style>
Try this code. When publish this code on IIS site works.
Check if your server accept googleapis and gstatic request.
Edit 2:
Comments:
<link rel="preconnect" href="https://fonts.googleapis.com">,<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>I recommend to delete":[email protected]"because in body section you can setup the font width .Also, try using font-family with single single quote
Edit 3
Just for discard default style on Plesk/Net Core/CSS Boostrap add !important.