public static Stream GetHttpStreamTransform(string xsltfilename, string xmlfilename) { var stream = new MemoryStream(); Stream tStream = new MemoryStream(); Stream xmlFileReader = RemoteData.GetRemoteStream(xmlfilename); Stream xsltFileReader = RemoteData.GetRemoteStream(xsltfilename); var writer = new StreamWriter(stream, Encoding.UTF8); XmlReader xmlr = XmlReader.Create(xsltFileReader); using (stream) { stream.Position = 0; if (xsltFileReader.ToString().IndexOf("OK") > -1) { tStream = XMLHelper.ApplyTransformation(xmlFileReader, xmlr); xmlFileReader.Close(); } else { tStream = xmlFileReader; } WebOperationContext.Current.OutgoingResponse.ContentType = "text/xml"; writer.Flush(); tStream.Position = 0; } xsltFileReader.Close(); xmlr.Close(); return(tStream); }