-1

In my ASP.NET Web Forms project, i am using bundling and minification. I want to use Fontawesome CDN with fallback support but problem is that only CDN is working and as a fallback my downloaded local Fontawesome is not working.

I am using StyleBundleFallback for stylebundle cdn fallback.

I have checked that i am referencing fontawesome correctly.

Although Bootstrap 5 is working fine but only fontawesome is not working.

Here is my code:


bundles.Add(new StyleBundle("~/webfont", fontico)

.IncludeFallback("~/Content/font-awesome/css/all.css", "sr-only", "width", 

"1px"));

Above code is working fine because it is using correct cdn url. You can try to modify this url to make a fallback so that it should use local fontawesome file but it is not working.

Creator
  • 7
  • 8
  • Describe "not working". What exact behavior are you seeing? What does the network tab of your browser's developer tools look like? – mason Jul 11 '19 at 13:57
  • i have checked page page view-source and found it rendered correctly in section. But its still not working. – Creator Jul 11 '19 at 15:22
  • It displaying nothing. – Creator Jul 11 '19 at 15:42
  • What HTML did it render? What did the network tab of your browser's developer tools look like? – mason Jul 11 '19 at 18:00
  • network tab of developer tools showing status: 307 for all.css (fontawesome css) and status - 200 for all others. – Creator Jul 11 '19 at 18:47
  • Okay. So what happens if you take that URL for the fontawesome css and navigate to it in your browser directly? Does it perform a redirect? Are you sure you have the right URL? – mason Jul 11 '19 at 18:55
  • I have copy url /Content/fontawesome/css/all.css from page view-source and open it in browser. The result is - it is opening google search instead of all.css file. – Creator Jul 12 '19 at 12:49
  • I have also try same process for bootstrap.css file and it is also opening google search page. Although it is working fine. – Creator Jul 12 '19 at 12:52
  • You have to provide a hostname to access. You can't just copy a part of a URL and expect it to find the right server. You need the entire https://somehost.com/path/to/file.css – mason Jul 12 '19 at 14:09
  • oh my mistake. After addin hostname, it is now opening css file. – Creator Jul 12 '19 at 15:27
  • I have modify fontawesome cdn url: – Creator Jul 12 '19 at 15:28
  • var fontico = "//use.fontawesome.com/releases/v5.6.3/css/cdndel"; – Creator Jul 12 '19 at 15:28
  • i have also took a screenshot of network tab but i don't know how to display it here. – Creator Jul 12 '19 at 15:33

1 Answers1

0

As far as I know, this works the other way around. i.e. tries the CDN first, fails to a local version of the library if the CDN isn't available.

Matt Evans
  • 7,113
  • 7
  • 32
  • 64