how to read contents webresponse with ContentEncoding = gzip RRS feed

  • Question

  • User-187584211 posted

    I have a asp.net web application which acts as a wrapper for the report server. I make a http web request and read the response from the SSRS using SteamReader and then use StreamWriter to write this response back to the browser.

    var request = (HttpWebRequest)HttpWebRequest.Create(uri);
    var response = request.GetResponse() as HttpWebResponse;

    I have implemented custom authentication and everything works in SSRS 2016, but I am facing problem with SSRS 2017.
    When I make a web request from our web application, I am able to get the response from SSRS but when I try writing back to the browser we get HTTP Error 500.19 - Internal Server Error. While debugging I noticed that the Response.ContentEncoding is gzip not sure if that is cause of it. I tried reading the gzip as below and then converting the content back to a stream with this code snippet. Even then we are not getting a proper result.

    if (response.ContentEncoding == "gzip")
        HttpClient client = new HttpClient();
        HttpResponseMessage response_;
        client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
        response_ = client.GetAsync(navRes.NavigatedTo).Result;
        text = response_.Content.ReadAsStringAsync().Result;
        text = new StreamReader(response.GetResponseStream()).ReadToEnd();

    am I missing anything here ? . Any help would be really appreciated

    Thanks & Regards,

    Anitha John

    Friday, June 8, 2018 12:39 PM

All replies