I am experiencing some problems while trying to export reports to PDF (or any format).
I have an asp.net MVC 3 website hosted on IIS 7.5 on a windows server 2008 R2 box.
The website allows reports to be viewed via SQL Server Reporting Services.
This all works fine until I try to remove the "Server" response header entry as detailed in Remove Server Response Header IIS7
The reports render fine in the report viewer control but when you try to export the report an exception is thrown, and the report fails to export.
After further investigation, it turns out that the following line causes the problem in the custom HTTP module - context.PreSendRequestHeaders += OnPreSendRequestHeaders;
namespace StrongNamespace.HttpModules
{
public class CustomHeaderModule : IHttpModule
{
public void Init(HttpApplication context)
{
context.PreSendRequestHeaders += OnPreSendRequestHeaders;
}
public void Dispose() { }
void OnPreSendRequestHeaders(object sender, EventArgs e)
{
HttpContext.Current.Response.Headers.Set("Server", "Box of Bolts");
}
}
}
Even if the method does nothing, the reports fail to export. The custom module works fine alongside the reports and they export ok if nothing is attached to the event.
There appears to be nothing useful in the event or SQL server logs.
The exception returned is:
The remote host closed the connection. The error code is 0x800704CD. \r\n \r\n at System.Web.Hosting.IIS7WorkerRequest.RaiseCommunicationError(Int32 result, Boolean throwOnDisconnect)\r\n \r\n at System.Web.Hosting.IIS7WorkerRequest.ExplicitFlush()\r\n \r\n at System.Web.HttpResponse.Flush(Boolean finalFlush)\r\n \r\n at System.Web.HttpWriter.WriteFromStream(Byte[] data, Int32 offset, Int32 size)\r\n \r\n at Microsoft.Reporting.WebForms.ReportDataOperation.StreamToResponse(Stream data, HttpResponse response)\r\n \r\n at Microsoft.Reporting.WebForms.ExportOperation.PerformOperation(NameValueCollection urlQuery, HttpResponse response)\r\n \r\n at Microsoft.Reporting.WebForms.HttpHandler.ProcessRequest(HttpContext context)\r\n \r\n at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()\r\n \r\n at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)\r\n", "ClientDetails": "{\"UserAgent\":\"Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)\",\"RawUrl\":\"/Reserved.ReportViewerWebControl.axd?ReportSession=l1lavh2yccrfzaexali5xe55&Culture=2057&CultureOverrides=True&UICulture=1033&UICultureOverrides=True&ReportStack=1&ControlID=24751adc9c9f47a387f0c486dc27fb48&OpType=Export&FileName=tp&ContentDisposition=OnlyHtmlInline&Format=PDF
Urlscan seems the to be the only remaining option to try, but I thought I'd see if anyone else had experienced similar problems.
Any advice or alternative ways of removing the Server header would be appreciated.
thanks, Malcolm
User contributions licensed under CC BY-SA 3.0