In this post, I'll explain a recent issue, our proposed fix, and what you need to know if you use our ASP.NET Core controls in .NET Core 3.x apps.
The Issue
We discovered an issue in ASP.NET Core's Razor engine which affects the client-side template syntax used by our DevExtreme-based ASP.NET Core Controls:
The Razor view engine can truncate parts of ERB-style constructs also known as 'percent tags' (<%= value %>
) which will in turn affect your client-side templates. To see a code example of this issue and it's effects, please take a look at this GitHub issue.
To make matters worse, at runtime, the output is empty and there are no errors in the browser console.
While Microsoft does not have a quick fix scheduled for this issue, we've got a fix ready and I'd like to get your feedback.
Our Fix
We have limited options in how we can fix this issue because the problem lies in the ASP.NET framework's Razor engine. However, we've come up with a simple and useful workaround.
We now provide an alternate syntax for client-side templates. Instead of using angle brackets (<% %>
), you can use square brackets [% %]
as template delimiters:
[% if(value > 0) { %]
<div>[%= value %]</div>
[% } else { %]
<div>(none)</div>
[% } %]
The new syntax is already available in our recently released maintenance updates 19.1.8 and 19.2.4. We've updated our documentation as well.
If this issue is important to you, then let Microsoft know and please vote here.
Should you have any questions about our new syntax or if you’d like to discuss your development needs further, please post a comment below. We’ll be happy to follow up.