Refused to apply style from 'https://localhost:44314/App.styles.css' because its MIME type ('') is not a supported stylesheet MIME type, and strict MIME checking is enabled.

Raj
Raj
Member
496 Points
21 Posts

Getting following error and css not getting loaded in local when env. set to qa:

Refused to apply style from 'https://localhost:44314/App.styles.css' because its MIME type ('') is not a supported stylesheet MIME type, and strict MIME checking is enabled.

Anyone has any clue?

Note: It's working fine when debugging with development env.

Views: 135
Total Answered: 3
Total Marked As Answer: 1
Posted On: 07-Apr-2024 23:11

Share:   fb twitter linkedin
Answers
Brian
Brian
Moderator
2232 Points
14 Posts
         

Refer here: https://learn.microsoft.com/th-th/aspnet/core/razor-pages/ui-class?view=aspnetcore-3.1&tabs=visual-studio#consume-content-from-a-referenced-rcl-1

When running the consuming app from build output (dotnet run), static web assets are enabled by default in the Development environment. To support assets in other environments when running from build output, call UseStaticWebAssets on the host builder in Program.cs:

using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;

public class Program
{
    public static void Main(string[] args)
    {
        CreateHostBuilder(args).Build().Run();
    }

    public static IHostBuilder CreateHostBuilder(string[] args) =>
        Host.CreateDefaultBuilder(args)
            .ConfigureWebHostDefaults(webBuilder =>
            {
                webBuilder.UseStaticWebAssets();
                webBuilder.UseStartup<Startup>();
            });
}
Posted On: 08-Apr-2024 01:25
Raj
Raj
Member
496 Points
21 Posts
         

Thanks for quick response. Works.

Posted On: 08-Apr-2024 04:18
kikme
kikme
Member
210 Points
10 Posts
         

Wow! it's great helpful.

Posted On: 09-Apr-2024 22:42
 Log In to Chat