问题
I am rendering a SSRS ServerReport to PDF and in the ReportViewer WebForm Control in a ASP.NET 3.5 Application with a SQL Server Report Service 2008.
Some people using Internet Explorer 11 reported that they cannot open generated PDF files or see anything in the viewer. The rendering fails with this error:
library!ReportServer_0-403!7c8!01/02/2014-11:07:37:: e ERROR: Throwing Microsoft.ReportingServices.Diagnostics.Utilities.InternalCatalogException: , Microsoft.ReportingServices.Diagnostics.Utilities.InternalCatalogException: Interner Fehler beim Berichtsserver. Weitere Informationen finden Sie im Fehlerprotokoll. ---> System.ArgumentNullException: Value cannot be null.
Parameter name: String
at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
at System.Web.Configuration.HttpCapabilitiesBase.get_MajorVersion()
at Microsoft.ReportingServices.Diagnostics.Utilities.BrowserDetectionUtility.GetBrowserInfoFromRequest(HttpRequest request)
at Microsoft.ReportingServices.Diagnostics.RSRequestParameters.SetBrowserCapabilities(HttpRequest request)
at Microsoft.ReportingServices.Library.RenderReportAction.SetBrowserCapabilities()
at Microsoft.ReportingServices.Library.RenderReportAction.PerformExecution()
at Microsoft.ReportingServices.Library.RenderReportAction.Render()
--- End of inner exception stack trace ---;
I could track these errors down to a OEM string used in the UserAgent of IE11.
Examples:
Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; MALC; rv:11.0) like Gecko
Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; MATM; rv:11.0) like Gecko
Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; NP06; rv:11.0) like Gecko
MALC, MATM and NP06 appear to be OEM strings and are not part of the usual IE11 UserAgent.
Removing these strings in IEs developer tools user agent settings makes everything work normally, but is not a solution for the end user.
Things I have tried:
- Overriding the UserAgent of the incoming Request in the ASP.NET application, but it appeared to never change regardless what I was setting. (I might have done this wrong, all I found was that I cannot change it so I tried anyway)
- Override the header at the Begin-/EndRequest event in the Global.asax
- Adding a custom .browser file in the App_Browser directory of the application itself and on the SSRS Server Application
What does work:
- Intercepting the request and making a custom Request using HttpWebRequest with a different UserAgent, copying cookies (session id) and request/response headers back and forth.
I feel like this is a horrible solution and should not be done like this.
How can I make SSRS not throw an error while parsing IE11s UserAgent?
Is there a way to disable it or add a custom Regular Expression to parse it manually?
回答1:
You can override the user agent to the report server by supplying additional device information.
This can be done when calling the Render method of the SOAP API by supplying this XML fragment as a parameter
<DeviceInfo>
<UserAgent>custom_user_agent_here</UserAgent>
</DeviceInfo>
Or using URL access like this
http://<Server Name>/reportserver?/SampleReports/Sales Order Detail&rs:Command=Render&rs:Format=HTML4.0&rc:UserAgent=custom_user_agent_here
.
References
Reporting Services Device Information Settings http://msdn.microsoft.com/en-us/library/ms155397(v=sql.110).aspx
HTML Device Information Settings http://msdn.microsoft.com/en-us/library/ms155395(v=sql.110).aspx
来源:https://stackoverflow.com/questions/20885786/ssrs2008-asp-net-serverreport-fails-on-ie11-with-oem-useragent