lundi 5 novembre 2018

Read pdf stream MVC Controller?

I get response from server as mentioned in this question enter link description here

enter image description here

Here is my code

 var response = new HttpResponseMessage();
        var content = new StringContent(incomingData, Encoding.UTF8, "application/json");
        using (HttpClient httpClient = new HttpClient())
        {
            httpClient.BaseAddress = new Uri(@"http://localhost:5488/api/report");
            response = httpClient.PostAsync(@"http://localhost:5488/api/report", content).Result;
            response.Content.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment");
            response.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/pdf");
        }

        var whatisThis = response.Content.ReadAsStringAsync().Result;
        byte[] returnValue = Convert.FromBase64String(whatisThis); //This returns error in conversion
        return new FileContentResult(returnValue, "application/pdf");

Where reponse is as mentioned above. Convert.FromBase64String returns error in converting this response. what is wrong with my code. Please help in detail




Aucun commentaire:

Enregistrer un commentaire