google font api not working asp.net mvc bundleconfig

Refresh

April 2019

Views

421 time

1

I'm currently working on an ASP.NET MVC application and I'm trying to include a google font into my bundleconfig.cs.

Unfortunately it does not work as expected. I'm getting this error:

The URL 'https://fonts.googleapis.com/css?family=Rokkitt:200,300,400,700' is not valid. Only application relative URLs (~/url) are allowed. Parameter name: virtualPath

My current coding in RegisterBundles method in BundleConfig.cs looks like this:

    string[] libraryCssList = new string[] 
    {
       "~/Content/css1.css",
       "~/Content/css2.css",
    }; // works fine

    // error begins:

bundles.UseCdn = true;

    var fontRokkittCss = "https://fonts.googleapis.com/css?family=Rokkitt:200,300,400,700";

    bundles.Add(new StyleBundle("~/Content/libraryCss")
    .Include(libraryCss)
    .Include(fontRokkittCss));

Do you know how to include google font api into a bundle config in asp.net mvc 4?

Thank you!!

0 answers