While running the veracode scan, a vulnerability has been thrown for the below line:
Page.Response.BinaryWrite(stream.GetBuffer());
Where, stream is an object of System.IO.MemoryStream.
I have tried the below line of code
Page.Response.BinaryWrite(Encoding.ASCII.GetBytes(HttpUtility.HtmlEncode(stream.GetBuffer())))
But, the same issue appears again in the scan.
Some details of the scan error:
Improper Neutralization of Script-Related HTML Tags in a Web Page (Basic XSS) (CWE ID 80)