Questions tagged [httpresponsemessage]

HttpResponseMessage refers to the C# public class that represents an HTTP response message including the status code and data. Use this tag for questions related to the public class.

HttpResponseMessage refers to the C# public class that represents an HTTP response message including the status code and data. Use this tag for questions related to the public class.

168 questions
21
votes
3 answers

Value cannot be null. Parameter name: request

I'm creating a unit test using nunit and all of this code works fine in runtime. I have this protected HttpResponseMessage code below that is being called by my controller when it returns. However, an error: "Value cannot be null. Parameter name:…
choopau
  • 2,209
  • 5
  • 21
  • 28
11
votes
1 answer

Convert HttpResponseMessage to ActionResult in Dot Net Core proxy controller action

The following method is intended to accept an Http method and url, execute the method against the url, and return the resulting response to the caller. It returns ActionResult because there are error conditions that need to be handled. At present,…
Larry Lustig
  • 49,320
  • 14
  • 110
  • 160
8
votes
1 answer

Difference between ContentDispositionHeaderValue.FileName and ContentDispositionHeaderValue.FileNameStar

We have a .Net Web application where the user can download files. The file name the files can have may contain danish characters æ, ø and å and maybe some other characters of some foreigh language. We use the class HttpResponseMessage to send the…
Jihad Haddad
  • 592
  • 1
  • 6
  • 19
6
votes
1 answer

How Can convert System.Net.Http.HttpResponseMessage to System.Web.Mvc.ActionResult

I'm Writing simple proxy application which get "URL Address" like "/xController/xMethod" and get result from another web application by HttpClient and show result. My Method: public ActionResult Index(string urlAddress) { var data = ""; if…
6
votes
1 answer

C# OAuth batch multipart content response, how to get all the contents not as string objects

I'm receiving a multipart content response that belongs to an OAuth batch request: // batchRequest is a HttpRequestMessage, http is an HttpClient HttpResponseMessage response = await http.SendAsync(batchRequest); If I read its content as full…
Max Xapi
  • 750
  • 8
  • 22
6
votes
1 answer

Microsoft Edge ignoring content disposition response header's FileName property?

I'm sending a file to the browser to be saved locally. This works fine in all browsers except Microsoft Edge, where it replaces the filename with a guid. The file has to be downloaded with a specific filename, is there an explanation or workaround…
Neil Humby
  • 253
  • 4
  • 15
6
votes
0 answers

HttpResponseMessage -Error while copying content to a stream

I am getting the exception below while posting message .Not sure why does this come. Any data points? Error while copying content to a stream var client = new HttpClient(new HttpClientHandler() { UseDefaultCredentials =…
CoolDiva
  • 209
  • 1
  • 3
  • 14
5
votes
1 answer

Convert HttpResponseMessage To XML to Object

I have defined the Serialization for my Object idAssignmentResult. But how do I convert an HttpResponseMessage that IS XML, to it's class? I am getting an error: Value of type 'System.Net.Http.HttpContent' cannot be converted to …
christopher clark
  • 2,026
  • 5
  • 28
  • 47
5
votes
3 answers

Stream from response.Content.ReadAsStreamAsync() is not readable randomly

I am making a .Net Web API application in which the following code is making call to my different c# application to download file and then save it on the disk. Sometimes everything works fine and I get the file but sometimes the below code is not…
4
votes
1 answer

HttpResponseMessage.Content is null

I've been working on both the backend and the frontend of a mobile application and am having trouble getting my post requests to work properly. I've been using Xamarin.Forms for the frontend and .Net for the backend. The code on the client side: var…
user3221924
  • 41
  • 1
  • 1
  • 4
3
votes
3 answers

Disposing of HttpResponseMessage is calling disposing of request's stream

I have a method that take Stream parameter and pass it to server public async Task Execute(Stream archive) { archive.Seek(0, SeekOrigin.Begin); using var content = new MultipartFormDataContent(); content.Add(new…
vitm
  • 473
  • 1
  • 3
  • 12
3
votes
3 answers

How to return a HttpResponseMessage in a .net Core MVC Controller without Serializing it as JSON?

I'm researching a web proxy pattern that makes use of ASP.Net Core MVC project type. I'd like to basically pass a HttpRequestMessage to a httpClient in the controller which then makes a request to a remote website (like https://www.abc.fake) and…
Paul Fryer
  • 9,268
  • 14
  • 61
  • 93
3
votes
1 answer

How do I get read through httpresponse to get return values:

I think I am close to getting this to work but am not sure how to get the contents to find out what the result message is returned in content to see if it is a good record or not, and I just don't know how. I've gotten close...can see my values in…
Rowan
  • 55
  • 1
  • 5
3
votes
1 answer

libcurl HTTP response message on 400 error

I'm sending an incorrect URL to a POST request via libcurl in C code. The server sends back a 400 along with a response containing detailed information about why the request was rejected. in libcurl i can see the error code: res CURLcode …
jmer
  • 371
  • 2
  • 12
3
votes
1 answer

Get Values from HttpRequestException in another application

I send Exception from one web application and get it in another. How do I can get values from HttpRequestException in this case? send from: context.Response = new HttpResponseMessage(apiError.StatusCode) { Content = new…
Kseniya Yudina
  • 137
  • 1
  • 11
1
2 3
11 12