hello, sql server report not load after add content security policy header in my Asp.net mvc project

Mrunali Patil 0 Reputation points
2025-08-02T16:55:16.8566667+00:00

Hello, I am adding below line in my asp.net web project in Web.config file. 'SSRS dll not register in project' error show in report viewer After adding this line

Content-Security-Policy: default-src 'self'; style-src 'self'; script-src 'self' ;frame-ancestors 'self'

Developer technologies | ASP.NET | Other
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Raymond Huynh (WICLOUD CORPORATION) 620 Reputation points Microsoft External Staff
    2025-08-04T03:50:59.9333333+00:00

    Hello @Mrunali Patil !

    Looking at this SQL Server Reporting Services (SSRS) issue, the problem is that your Content Security Policy (CSP) header is blocking the SSRS report viewer from loading properly.

    The CSP header you added:

    Content-Security-Policy: default-src 'self'; style-src 'self'; script-src 'self' ;frame-ancestors 'self'
    

    This is too restrictive for SSRS reports, which need to load external resources and scripts from the SQL Server instance.

    Here's how to fix it:

    Option 1: Modify your CSP header to allow SSRS resources

    Add the necessary sources for your SSRS server:

    Content-Security-Policy: default-src 'self' https://your-ssrs-server.com; style-src 'self' 'unsafe-inline' https://your-ssrs-server.com; script-src 'self' 'unsafe-eval' https://your-ssrs-server.com; frame-ancestors 'self' https://your-ssrs-server.com
    

    Option 2: Use a more permissive CSP for the report pages

    Create a separate CSP for pages that contain SSRS reports:

    Content-Security-Policy: default-src 'self' https://your-ssrs-server.com; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-eval' 'unsafe-inline'; frame-ancestors 'self'
    

    Option 3: Temporarily disable CSP for testing

    If you're just testing, you can temporarily comment out the CSP header to confirm it's the cause:

    <!-- Content-Security-Policy: default-src 'self'; style-src 'self'; script-src 'self' ;frame-ancestors 'self' -->
    

    The key issues are:

    • SSRS needs to load scripts and styles from the SQL Server instance
    • The 'unsafe-eval' directive is often required for SSRS report viewer
    • Frame-ancestors needs to include your SSRS server URL

    Replace https://your-ssrs-server.com with your actual SSRS server URL. If you're using a local instance, it might be something like http://localhost:8080 or your server's internal URL.

    Hope this helps resolve your SSRS loading issue!


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.