ClientTemplate causing issue with strict CSP

1 Answer 202 Views
Grid
Laxmi
Top achievements
Rank 1
Laxmi asked on 30 May 2023, 02:27 PM

Hi,

I am working on making application CSP complaint using  UI for ASP.NET MVC R1 2023 SP2 (version 2023.1.425).

Grid column is having ClientTemplate which is causing grid to be empty. This was working prior.

Below is the code snippet:

.ClientTemplate("<a target='_blank' href=" + @Url.Action("ReportRouter", "Reports") + "?reportId=#=ReportId#>#=DisplayName#</a>");

 

Developer tool is showing Invalid template error. I have also added 

@(Html.Kendo().DeferredScriptFile())

 

Any input is appreciated.

 


1 Answer, 1 is accepted

Sort by
0
Anton Mironov
Telerik team
answered on 02 Jun 2023, 11:15 AM

Hello Laxmi,

Thank you for the code snippet and details provided.

In order to achieve the desired result, I would recommend using a function handler.

From the function handler, use an Ajax Request to the "ReportRouter" Action Method and return the needed content.

Give a try to the approach above and let me know if is achieves the desired result.

Kind Regards,
Anton Mironov
Progress Telerik

As of R2 2023, the default icon type will be SVG instead of Font. See this blogpost for more information.

abdul
Top achievements
Rank 2
Iron
Iron
commented on 15 Jul 2025, 03:26 PM

Hi,

Any update on this how to fix the above issue. I am also facing the same issue. ClientTemplate is not able to recognize when using @(Html.Kendo().DeferredScriptFile())

Anton Mironov
Telerik team
commented on 18 Jul 2025, 08:54 AM

Hi Abdul,

The issue comes from using a strict Content Security Policy (CSP) together with the Grid's ClientTemplate, which relies on inline templates. Strict CSP blocks inline JavaScript, causing templates to fail and the grid to appear empty. The use of @(Html.Kendo().DeferredScriptFile()) helps move scripts to external files, but it does not resolve issues with inline templates.

Solution: Use ClientTemplateHandler for CSP Compliance.

Instead of using .ClientTemplate(), use .ClientTemplateHandler(). This lets you define the template logic in an external JavaScript function, which is allowed by strict CSP.

I hope this information helps.

Best Regards,
Anton Mironov
Tags
Grid
Asked by
Laxmi
Top achievements
Rank 1
Answers by
Anton Mironov
Telerik team
Share this question
or