KB: Anti-XSS 3.0 Security Runtime Engine causing blank TemplateField columns in ASP.NET GridView

 

Problem: When using Anti-XSS 3.0 Beta Security Runtime Engine (i.e. the http module), data binding <%#Eval(xxx)%> in TemplateField column of ASP.NET GridView becomes blank. However, BoundField column is not affected.

Example:

image becomes

clip_image002

Resolution: Exclude the page / GridView from the Anti-XSS SRE, and use Anti-XSS Library encode methods in the data binding expression.

Example: <%#Microsoft.Security.Application.AntiXss.HtmlAttributeEncode((string)Eval(xxx))%>

image