I am developing a web application that manages a population of plants. One feature of the application is the ability to view relationships between plants as a graph. This visualisation is generated as a dot file, then turned into SVG using GraphViz. The resulting SVG markup is then rendered to the browser via an .aspx file, using the Response.Write() technique.
Aspx markup:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Visualisation.aspx.cs" Inherits="Webapp.PopulationManager.Visualisation" %>
Codebehind:
protected void Page_Load(object sender, EventArgs e)
{
if(!Page.IsPostBack)
{
// ...snip...
string svgString = PopulationModule.VisualiseTable(connectionTable, title, url.ToString());
Response.Clear();
Response.ClearContent();
Response.ClearHeaders();
Response.ContentType = "image/svg-xml";
Response.AddHeader("Content-Disposition", string.Format("inline;filename={0}", filename));
Response.Write(svgString);
Response.Flush();
}
}
This techniques works perfectly on my Windows development machine (a dialog pops up asking me to save/open the SVG file).
However it fails when deployed to the Linux server that is hosting this app - the page returns the SVG markup, but a garbage string of about 5-6 characters is added as the first line, causing the browser to fail parsing the SVG file.
The Linux host runs RHEL5, Mono 1.9, and Lighttpd (with fast-cgi to talk to Mono).
I have verified that the SVG markup is generated cleanly on the Linux server; and if I run the web app with XSP2 instead of Lighttpd, the page works as expected. The garbage line is added somewhere after the SVG markup is generated (so I can't simply remove the first line before writing out the response).
Does anyone know what might be causing this? Options, ideas, and thoughts greatly recieved!
Thanks.
EDIT:
The characters vary depending on the entity I create a visualisation for - but remain the same for a given entity. So if I create an SVG visualtion for object A, I'll always get the string 1f35 as garbage in the first line.