ReportViewer “Missing URL parameter: Name”

浪尽此生 提交于 2019-12-22 08:20:08

问题


In a web application I'm working on the ReportViewer keeps giving me a error "Missing URL parameter: Name". I have found the cause but not a solution.

The url that is causing the exception from the report viewer

Reserved.ReportViewerWebControl.axd?ReportSession=3bkunv2wte3wmnabkquyr1y0&ControlID=1e2b5870e07b46abac7fd32a9e0e4b9d&Culture=1033&UICulture=1033&ReportStack=1&OpType=ReportArea&Controller=ctl00_ASPxRoundPanel3_PageContent_Wizard1_ReportViewer1&PageNumber=1&ZoomMode=Percent&ZoomPct=100&ReloadDocMap=true&SearchStartPage=0&LinkTarget=_top

if you notice in the query string instead of "&name=" for some reason it becomes "&amp ;Name=".

I noticed on numinous google searches there seams to be a lot of people having the same problem but not one solution.


回答1:


Sounds like something is mangling your URL somewhere. Do you by chance have a Bluecoat proxy in place? I saw something about Bluecoat mangling the URL.

If that's the case and you have control over the proxy, you might be able to get a tunnel punched through it for your reports. Otherwise, you might have to rewrite the URL on your end.

Check here for more information (last post in the thread has a possible workaround).




回答2:


You can fix this globally by checking for the BlueCoat request header at the start of each request. This bit of code placed in global.asax.cs fixes the problem:

protected void Application_BeginRequest(Object sender, EventArgs e) 
{
    // Fix incorrect URL encoding by buggy BlueCoat proxy servers:
    if (!String.IsNullOrEmpty(Request.ServerVariables["HTTP_X_BLUECOAT_VIA"]))
    {
        string original = Request.QueryString.ToString();

        if (original.Contains(Server.UrlEncode("amp;"))) 
        {
            HttpContext.Current.RewritePath(Request.Path + "?" + original.Replace(Server.UrlEncode("amp;"), "&"));
        }
    }
}

I'm not sure if any other proxy servers have the same issue, but if they do, this could be easily be adapted to check for the presence of & in the QueryString instead of checking for the BlueCoat header (or I guess, you could just check for the headers of any other affected products, which might be safer.



来源:https://stackoverflow.com/questions/705359/reportviewer-missing-url-parameter-name

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!