I was writing a Razor MacroScript that displays an event and also has the option to export the event to iCalendar format. I was performing the export by writing the contents of the iCalendar file to the response stream (eg. HttpContext.Current.Response). Before doing so I was clearing all headers and afterwards I called Response.End()
Whilst this worked fine, I noticed a load of extra output was being appended to the output *after* I'd called Response.End(). Here is a simple example of code within a macroscript that illustrates the problem:
Bug? Trace Output ALWAYS in Response Stream
I was writing a Razor MacroScript that displays an event and also has the option to export the event to iCalendar format. I was performing the export by writing the contents of the iCalendar file to the response stream (eg. HttpContext.Current.Response). Before doing so I was clearing all headers and afterwards I called Response.End()
Whilst this worked fine, I noticed a load of extra output was being appended to the output *after* I'd called Response.End(). Here is a simple example of code within a macroscript that illustrates the problem:
You would expect this just to be output:
TESTING 123
However, what you actually get is this:
TESTING 123 <div id="__asptrace"> <style type="text/css"> span.tracecontent b { color:white } span.tracecontent { background-color:white; color:black;font: 10pt verdana, arial; } span.tracecontent table { clear:left; font: 10pt verdana, arial; cellspacing:0; cellpadding:0; margin-bottom:25} span.tracecontent tr.subhead { background-color:#cccccc;} span.tracecontent th { padding:0,3,0,3 } span.tracecontent th.alt { background-color:black; color:white; padding:3,3,2,3; } span.tracecontent td { color: black; padding:0,3,0,3; text-align: left } span.tracecontent td.err { color: red; } span.tracecontent tr.alt { background-color:#eeeeee } span.tracecontent h1 { font: 24pt verdana, arial; margin:0,0,0,0} .... hundreds more lines.... Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1
I tried disabling Trace in the web.config and also debugging but this still occurs.
Obviously this screws up exporting to files within a Razor script (or code called from within a razor script).
I've created the following issue report in Codeplex: http://umbraco.codeplex.com/workitem/30664
is working on a reply...