question

AvblSundari-7377 avatar image
0 Votes"
AvblSundari-7377 asked FredericDruilhet answered

Refused to apply style from <URL> because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled

HI Team,

I'm trying to to bundling CSS files after minification. My application is ASP.net Core 4.5 not MVC. I have created bungleconfig class file and written below code

public class bundleconfig
{
// For more information on bundling, visit http://go.microsoft.com/fwlink/?LinkId=301862
public static void RegisterBundles(BundleCollection bundles)
{

         bundles.Add(new StyleBundle("~/bundles/css").Include(
                       "~/Content/bootstrap.min.css",
                       "~/Content/main.min.css",
                        "~/Content/theme.min.css",
                       "~/Content/bootstrap-select.min.css",
                       "~/Content/bootstrap-slider.min.css",
                       "~/Content/bootstrap-theme.min.css",
                       "~/Content/bootstrap-treeview.min.css", 
                       "~/Content/bootstrap-datetimepicker.min.css",
                        "~/Content/buttons.dataTables.min.css",
                         "~/Content/dataTables.bootstrap.min.css",
                          "~/Content/jquery-ui.min.css",
                         "~/Content/bootstrap-treeview.min.css"
                   )
             );
         BundleTable.EnableOptimizations = true;
     }
 }

in Main.Maste I added below code in head tag

<%: System.Web.Optimization.Styles.Render("~/bundles/css") %>

After running code MY css is not bundled and nothing applied as well. Getting error

Refused to apply style from <URL> because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.

Please help

Thanks In advance

dotnet-csharpdotnet-aspnet-webforms
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

YijingSun-MSFT avatar image
0 Votes"
YijingSun-MSFT answered

Hi @AvblSundari-7377 ,
I think the MIME Type error could be due to the css path not being correct. How do add css file in your page? You could check it. And you could try use absolute path.
Best regards,
Yijing Sun


If the answer is helpful, please click "Accept Answer" and upvote it.

Note: Please follow the steps in our  documentation  to enable e-mail notifications if you want to receive the related email notification for this thread.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

FredericDruilhet avatar image
0 Votes"
FredericDruilhet answered

Same problem here. Resolved in setting BundleTable.EnableOptimizations to false

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.