I am using a StringBuilder in an ashx file to return javascript. It all works fine, except for one line...
javascript.Append("document.write(\"<script id=__ie_onload defer \" + \"src=javascript:void(0)><\/script>\");");
For readability, here is the unescaped version:
document.write("<script id=__ie_onload defer src=javascript:void(0)><\/script>");
If I comment out this line, my ashx file works like a charm! If I keep it in, though, it won't even run. Is there some sort of restriction on using a document.write statement in a StringBuilder? Alternatively, is there a better way to write out Javascript from within .NET? It has to be from .NET due to the need for using server variables.