小编BId*_*ude的帖子

WebRequest在ASP.NET应用程序中失败,"414 Request URI太长"

我们有一个ASP.NET应用程序,它在将报告的参数作为WebRequest传递后,以HTML格式请求SSRS 2005报告.只有在请求具有大量多选参数的报表时,应用程序才会失败,从而在该webRequest.GetResponse()行处抛出"414:Request URI too long"错误.

用于发出请求的代码是:

HttpWebRequest webRequest = null;
HttpWebResponse webResponse = null;
string webRequestURL = _ReportManager.GetRSUrl(reportID); //this passes the report link on the SSRS server

//make the request

Byte[] bytes = Encoding.UTF8.GetBytes("xml_doc=" + HttpUtility.UrlEncode(webRequestURL));

webRequest = (HttpWebRequest)WebRequest.Create(webRequestURL);
webRequest.Method = "POST";
webRequest.ContentLength = bytes.Length;
webRequest.Timeout = Configuration.WebRequestTimeOut;

RSExecution2005.ReportExecutionService rsE = new RSExecution2005.ReportExecutionService();
rsE.Url = Configuration.ReportExecutionServiceUrl2005;
rsE.Credentials = System.Net.CredentialCache.DefaultCredentials;
webRequest.Credentials = rsE.Credentials;

Stream reqStream = null;
reqStream = webRequest.GetRequestStream();
reqStream.Write(bytes, 0, bytes.Length);
reqStream.Close();

webResponse = (HttpWebResponse)webRequest.GetResponse();
Run Code Online (Sandbox Code Playgroud)

由于报告在服务器端失败,我已经查看了IIS和ReportServer属性,以字节方式增加maxUrl,maxRequestLength,MaxQueryString等(根据本文 …

c# iis httpwebrequest reporting-services getresponse

10
推荐指数
2
解决办法
1万
查看次数