tags:

views:

211

answers:

4

Hi all,

I'd like to know if I can send an HttpWebRequest without waiting for a response (using .NET).

I am interested in SENDING information, but I don't care about the response.

Do I HAVE to wait for the response? Or I'm safe to just issue the request?

I guess it's the same question as:

http://stackoverflow.com/questions/449506/how-to-send-http-request-in-asp-net-without-waiting-for-a-response-and-without-ty

Thanks in advance.

+1  A: 

I guess this depends on what you value - and how the response affects that. Do you care what the response might contain? Do you care whether the user knows about the result? Do you care whether you application's functions are working at all?

If you don't care, at all, about the results of the outgoing messages, then it seems that you can ignore the results.

Argalatyr
A: 

Well, aren't you interested in whether your request has been received on the server?

If you don't even care about that, it seems like you don't need to send anything in the first place.

Why don't you care about the response? (Or rather, why do you think you don't care about the response?)

jalf
+1  A: 

No you can't just ignore it, in order to ensure the server processes the request you need to ensure something is listening for a response.

The async solution in the other question is the answer. As others have said surely there must be some degree of interest in the request?

AnthonyWJones
A: 

The behavior depends upon the server logic for processing the request. For e.g., in ASP.NET if you are processing a long request you have the option to check Request.IsClientConnected periodically to ensure that the client is connected and waiting for the response. You can decide to terminate the processing if the client has disconnected. This helps in saving precious server resources for long running requests.

If you control the server then you should be fine with sending the request and terminating without waiting for response. If the server is not yours, you may try doing trial and error to figure out the server behavior.

PS: I assume you don't care about any server errors upon your request. If you need to ensure that your request succeeded, you'll have to wait for the response.

Shiva