Bad Request – Request Too Long
HTTP Error 400. The size of the request headers is too long.
When you use the “Microsoft.ReportViewer.WebForms”control in asp.net
You’ve eaten too many cookies Reserved.ReportViewerWebControl.axd
If like me you use the report viewer control to display reports from SSRS to the world wide web you may have come across an ever increasing number of cookies from the control.
I don’t really have time to look into this in any detail as im working to a deadline at the moment and as such need to resolve this asap.
I think this is perhaps something to do with the fact I am using masterpages with iframes to both separate the CSS and pull out the parameters into an intermediate step.
Anyway my solution was to wipe the cookie from the request cookies collection so they dont get a chance to stack up.
Create class in you App_Code and past the following code into the file
you could adapt this to only delete if the number of cookies exceeded a certain level
Public Class httpModuleClearReportViewerControlCookies
Implements IHttpModule, SessionState.IRequiresSessionState
Public Sub Dispose() Implements IHttpModule.Dispose
Public Sub Init(context As HttpApplication) Implements IHttpModule.Init
Dim DeleteList As New List(Of String)
For Each oCookie In context.Request.Cookies
If oCookie.ToLower.Contains("reserved.reportviewerwebcontrol") Then DeleteList.Add(oCookie)
For Each Cookie As String In DeleteList