Questions tagged [httpwebrequest]

HttpWebRequest is a concrete class for .NET Framework applications that provides an HTTP-specific implementation of the abstract WebRequest class. Related tag: [webrequest].

The HttpWebRequest class provides support for the properties and methods defined in WebRequest and for additional properties and methods that enable the user to interact directly with servers using HTTP.

Do not use the HttpWebRequest constructor. Use the WebRequest.Create method to initialize new HttpWebRequest objects. If the scheme for the Uniform Resource Identifier (URI) is http:// or https://, Create returns an HttpWebRequest object.

The GetResponse method makes a synchronous request to the resource specified in the RequestUri property and returns an HttpWebResponse that contains the response. You can make an asynchronous request to the resource using the BeginGetResponse and EndGetResponse methods.

When you want to send data to the resource, the GetRequestStream method returns a Stream object to use to send data. The BeginGetRequestStream and EndGetRequestStream methods provide asynchronous access to the send data stream.

For client authentication with HttpWebRequest, the client certificate must be installed in the My certificate store of the current user.

The HttpWebRequest class throws a WebException when errors occur while accessing a resource. The WebException.Status property contains a WebExceptionStatus value that indicates the source of the error. When WebException.Status is WebExceptionStatus.ProtocolError, the Response property contains the HttpWebResponse received from the resource.

HttpWebRequest exposes common HTTP header values sent to the Internet resource as properties, set by methods, or set by the system; the following table contains a complete list. You can set other headers in the Headers property as name/value pairs. Note that servers and caches may change or add headers during the request.

You can find the documentation for the class on MSDN.

5585 questions
2
votes
2 answers

Parallel.For WebRequests - The first requests is just doing nothing

I've got a list of Accounts. I want to login with all accounts on a website. I want to use Parallel.ForEach to process all accounts. This is what my code looks like: Parallel.ForEach(Accounts, acc => { acc.WebProxy = null; …
Florian
  • 5,918
  • 3
  • 47
  • 86
2
votes
1 answer

C# JIRA work-log update error "The remote server returned an error: (401) Unauthorized."

Im going to update work log of an issue in JIRA via the JIRA REST API on c# application. Following codes shows what I have done so far. HttpWebResponse return this error "The remote server returned an error: (401) Unauthorized.". I tried this with…
iJay
  • 4,205
  • 5
  • 35
  • 63
2
votes
2 answers

Receiving and handling a GET request in PHP

I'm trying to replace RSS polling with PubSubHubbub on my site. I'm able to use the subscriber library that google offers to send the subscription request. From the code it looks like it sends a post request via cURL with the RSS URL and a callback…
2
votes
1 answer

HttpWebRequest losing cookies

I have a client application that is communicating with an ASP.NET web service using cookie-based authentication. (the clients call a login method which sets a persistent cookie that is then re-used across requests within the logon session). This…
homeInAStar
  • 226
  • 2
  • 5
2
votes
2 answers

How to create HttpWebRequest without interrupting async/await?

I have a bunch of slow functions that are essentially this: private async Task> DownloadSomething() { var request = System.Net.WebRequest.Create("https://valid.url"); ... using (var ss = await…
GSerg
  • 76,472
  • 17
  • 159
  • 346
2
votes
0 answers

Limit HttpWebRequest request&response sizes

Is there a way to limit request\response sizes for HttpWebRequest, WebClient, HttpClient and other ways to communicate with network? I know that we can set concurrency limit ServicePointManager.DefaultConnectionLimit and maximum size of request for…
Sergey Litvinov
  • 7,408
  • 5
  • 46
  • 67
2
votes
1 answer

The remote server returned an error: (403) Forbidden in Asp.net C# Instagram.(HttpWebRequest)

When I access response = request.GetResponse();// request is a HttpWebRequest's object The remote server returned an error: (403) Forbidden. error. But when i execute the url in the request in my browser URL, it gets redirected to the page which I…
Murali
  • 21
  • 1
  • 3
2
votes
1 answer

WebPermission Exception even though I'm in Full trust

I'm trying to do what I thought was a simple HttpWebRequest (the code is deep inside a dll so I can't give a small code snippet, but it should be relatively simple), but I'm getting a security exception: System.Security.SecurityException: Request…
Paul
  • 9,409
  • 13
  • 64
  • 113
2
votes
3 answers

How large can a HTTP form parameter string be?

How large can a HTTP form parameter string be? If I want to pass say a couple of pages worth of XML will a form parameter be ok? Or if not would I need to treat it as a file upload to be sure? Thanks
Greg
  • 34,042
  • 79
  • 253
  • 454
2
votes
0 answers

Downloaded mp3 stream is not Playing from IsolatedStorage in windows phone 7

I have downloaded a .mp3 Song in my application using HttpWebRequest and WebClient Both. I am saving the response stream in Isolated Storage with .mp3 extension filename. When i m trying to play it with BackgroundAudioPlayer it do not plays. Here is…
2
votes
2 answers

How to read someone else's forum

My friend has a forum, which is full of posts containing information. Sometimes she wants to review the posts in her forum, and come to conclusions. At the moment she reviews posts by clicking through her forum, and generates a not necessarily…
Ziggy
  • 21,845
  • 28
  • 75
  • 104
2
votes
1 answer

HttpWebRequest cannot connect through proxy?

I am trying to achieve something that should be simple according to everything I have read, but is just not working for me: send any request through a proxy. Please see the code below; it works as long as the 2 lines are commented out. Once I put…
denious
  • 163
  • 1
  • 11
2
votes
1 answer

HttpWebRequest.Create returns (500) Internal Server Error

It works fine to browse this page : http://www.litteraturmagazinet.se/arga-bibliotekstanten/boklogg/favorit-i-repris-9560835 in a regular browser(for example Chrome). But when I use the following code to fetch the website I get Internal Server Error…
Banshee
  • 15,376
  • 38
  • 128
  • 219
2
votes
3 answers

Getting a file into Request.Files

I have a device that uses a custom scripting language. This language provides the capability to set http request headers then perform a post to a URL. The server that the device communicates with is running .net, and I would like the handler on the…
Ted Shaffer
  • 71
  • 1
  • 4
2
votes
1 answer

How to make an HTTP request using a custom verb?

In order to test an API, I want to be able to make HTTP requests using custom verbs (such as "RECOMPUTE")¹, other than GET, POST, PUT, DELETE, OPTIONS, HEAD, TRACE and CONNECT. Is there a library which already does that, or do I have to reinvent the…
Arseni Mourzenko
  • 50,338
  • 35
  • 112
  • 199
1 2 3
99
100