Hi - thanks for the reply. I think this is the code you are referring to, yes?
public class GetDoc : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
if (context.Request.QueryString[“docName”] != null && context.Request.QueryString[“projectID”] != null)
{
int projectID = int.Parse(context.Request.QueryString[“projectID”]);
string templateDoc = context.Request.QueryString[“DocName”];
if (projectID != 0 && !string.IsNullOrEmpty(templateDoc))
{
Stream outputStream = new MemoryStream();
// Set contenttype and clear headers
context.Response.Clear();
switch (DocGenerator.GetDocumentType(templateDoc))
{
case DocumentType.PDF:
context.Response.ContentType = “application/pdf”;
DocGenerator.GenerateDocument(projectID, templateDoc, ref outputStream);
break;
case DocumentType.WORD_DOC:
case DocumentType.WORD_DOCX:
case DocumentType.WORD_DOTM:
context.Response.ContentType = “application/msword”;
DocGenerator.GenerateDocument(projectID, templateDoc, ref outputStream);
break;
default:
outputStream = new MemoryStream(DocGenerator.GetRawFile(templateDoc));
break;
}
// Write the memory stream to response stream
MemoryStream stream = (MemoryStream)outputStream;
stream.WriteTo(context.Response.OutputStream);
string saveAs = context.Request.QueryString[“OutputDocName”];
if (!string.IsNullOrEmpty(saveAs))
context.Response.AddHeader(“content-disposition”, “attachment;filename=”" + saveAs + “”");
else
context.Response.AddHeader(“Content-Disposition”, “attachment; filename=”" + templateDoc + “”");
// Buffer response so that page is sent
// after processing is complete.
context.Response.BufferOutput = true;
// Send the output to the client.
context.Response.Flush();
}
}
}