Note that there are some explanatory texts on larger screens.

plurals
  1. POWebRequest fails with "414 Request URI too long" in ASP.NET application
    primarykey
    data
    text
    <p>We have an ASP.NET application that requests an SSRS 2005 report in HTML format after passing the parameters for the report as a WebRequest. The application only fails when a report with a large number of multi-select parameters is requested, throwing a "414: Request URI too long" error at the <code>webRequest.GetResponse()</code> line.</p> <p>The code used to make the request is:</p> <pre><code>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(); </code></pre> <p>As the report fails on the server side, I have looked into IIS and ReportServer properties to increase the maxUrl, maxRequestLength, MaxQueryString, etc. in terms of bytes (as per <a href="http://www.iis.net/configreference/system.webserver/security/requestfiltering/requestlimits" rel="noreferrer">this article</a>) but the application still throws an error. I have tried this in the web.config files and directly on the IIS manager.</p> <p>The reporting server version in 2005 and it is hosted on Windows Server 2008, which is running IIS 7.</p> <hr> <p>On David Lively's advise I tried requesting the URI by putting the parameters in the body. This works for smaller requests, but still fails for large multi-select parameters. The amended code is as follows:</p> <pre><code>HttpWebRequest webRequest = null; HttpWebResponse webResponse = null; string webRequestURL = _ReportManager.GetRSUrl(reportID); //this passes the report link on the SSRS server string postData = string.Empty; string URIrequest = string.Empty; URIrequest = webRequestURL.Substring(0, webRequestURL.IndexOf("&amp;")); int requestLen = webRequestURL.Length; int postDataStart = webRequestURL.IndexOf("&amp;") + 1; postData = webRequestURL.Substring(postDataStart, (requestLen - postDataStart)); Byte[] bytes1 = Encoding.UTF8.GetBytes(postData); webRequest = (HttpWebRequest)WebRequest.Create(URIrequest); webRequest.Method = "POST"; webRequest.ContentType = "application/x-www-form-urlencoded"; webRequest.ContentLength = bytes1.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 = webRequest.GetRequestStream(); reqStream.Write(bytes1, 0, bytes1.Length); reqStream.Close(); webResponse = (HttpWebResponse)webRequest.GetResponse(); </code></pre> <p>Even though the requestURI of the webRequest does not store parameters, it seems that the GetReponse() function adds the parameters to the 'address' property of the webRequest. could this be the problem? if so, how can it be fixed.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload