In Global.asax I have added below event and it worked like a charm
void Application_PostReleaseRequestState(object sender, EventArgs e)
{
//add no script tag for 508 compatibility
if(Response.ContentType == "text/html")
{
//add no script tag for 508 compatibility
Response.Filter = new NoScriptTagAppendFilter(Response.Filter);
}
}
public NoScriptTagAppendFilter(Stream stream)
{
outputStream = stream;
}
public override void Write(byte[] buffer, int offset, int count)
{
//base.Write(buffer, offset, count);
string data = UTF8Encoding.UTF8.GetString(buffer);
data = Regex.Replace(data, "</script>", "</script><noscript></noscript>");
outputStream.Write(UTF8Encoding.UTF8.GetBytes(data), offset, UTF8Encoding.UTF8.GetByteCount(data));
data = null;
}
This would definitely help someone in future who wants to 508 compatibility for script generated by Ajax & testing using http://achecker.ca/checker/index.php