Disable the Content-Security-Policy header

RECOMENDATION: We do not recommend disabling the Content-Security-Header. This can make your site vulnerable to various attacks, such as Cross-Site Scripting (XSS). We recommend configuring the header instead.
For more information, see Configure Content-Security-Policy header.

To disable sending the header, perform the following:

  1. Open the Program.cs file of Sitefinity ASP.NET Core Renderer.
  2. Modify the services section in the following way:
    C#
    using Microsoft.AspNetCore.Builder;
    using Microsoft.AspNetCore.Hosting;
    using Microsoft.Extensions.Hosting;
    
    using Progress.Sitefinity.AspNetCore;
    using Progress.Sitefinity.AspNetCore.FormWidgets;
    
    var builder = WebApplication.CreateBuilder(args);
    
    // Add services to the container.
    
    // Disable CSP header
    builder.Services.AddSitefinity(x => x.CspOptions.Disabled = true); 
    
    builder.Services.AddViewComponentModels();	
    builder.Services.AddFormViewComponentModels();	
    
    var app = builder.Build();	
    
    // Configure the HTTP request pipeline.	
    if (app.Environment.IsDevelopment())	
    {	
        app.UseDeveloperExceptionPage();	
    }	
    else	
    {	
        app.UseExceptionHandler("/Error");	
        app.UseHsts();	
    }	
    
    app.UseStaticFiles();	
    app.UseRouting();	
    app.UseSitefinity();	
    
    app.UseEndpoints(endpoints =>	
    {	
        endpoints.MapSitefinityEndpoints();	
    });	
    
    app.Run();	
  3. Save and close the Program.cs file.
  4. Build and deploy the renderer application.
Want to learn more?
Enhance your Sitefinity skills by enrolling in free training sessions. Become Sitefinity certified through Progress Education Community to strengthen your professional credentials.
New to Sitefinity?