Questions tagged [system.net.httpwebrequest]

Provides an HTTP-specific implementation of the WebRequest, an abstract base class for the .NET Framework's request/response model for accessing data from the Internet class.

Provides an HTTP-specific implementation of the WebRequest, an abstract base class for the .NET Framework's request/response model for accessing data from the Internet class.

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.

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.

http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.aspx

182 questions
4
votes
1 answer

Get IE's default proxy with DefaultWebProxy

I've read through pretty much all the documentation I can find but I'm yet to find a simple working example of how to get IE's default proxy settings using DefaultWebProxy(). This code seems to compile and work but how do I then go ahead and get the…
Paul Matthews
  • 2,164
  • 5
  • 20
  • 29
4
votes
2 answers

An API rate limiter

I wrote an API rate limiter to use with Last.fm's API. Last.fm's Tos states that I cannot make more than 5 requests per originating IP address per second, averaged over a 5 minute period. Here is the class I wrote: public class RateLimiter { …
jjdev80
  • 461
  • 4
  • 17
3
votes
0 answers

Downloading a file with RTL characters in the name, with C# WebRequest

I am trying to download a file which has hebrew characters in the name https://example.com/path/‏צילום מסך 2014‏.04‏.16 ב‏.16.44.30.png When I try to download with the browser, the filename is correctly encoded and the server returns the file. If…
3
votes
3 answers

How do I get the current cookie / session ID from a HttpResponseMessage?

I try to use the new .net 4.5 HttpClient from System.net.http. I set-up my client like this CookieContainer cookieJar = new CookieContainer(); HttpClientHandler handler = new HttpClientHandler { CookieContainer =…
silverfighter
  • 6,762
  • 10
  • 46
  • 73
2
votes
1 answer

why certificates are null using .NET Core 2 but it works just fine with .NET Framework 4.6.2?

I have been doing some test migrating .NET Framework 4.6.2 apps to .NET Core 2. I noticed that this particular app, a monitoring http is not working fine with Net Core 2. Can you please help me to verify what is happening? static void Main(string[]…
2
votes
3 answers

HttpWebRequest returning error "The underlying connection was closed"

I simply need to call a web page and get the response page back. I use the following code to call the webpage. This code has been working great for months. However, just recently, the line that calls GetResponse is now returning the error "The…
2
votes
2 answers

ASP.NET Core Modify HTTP Request Headers using Middleware

All I need to do is to modify [Connection] HTTP Header from "Keep-alive" to lowercase "keep-alive". I wrote the class, public class PreRequestModifications { private readonly RequestDelegate _next; public…
realPro
  • 1,713
  • 3
  • 22
  • 34
2
votes
0 answers

Getting random timeouts when connecting to server

I randomly get a timeout exception when making a request to the server. I've been trying httpwebrequest, restsharp and httpclient. I can't use HttpClient because I need to add custom certificates and they're not implemented. This is what I've found…
2
votes
2 answers

How to validate SSL Certificate for Web request using ASP.NET Core

I had implemented a method for getting the response from a REST API request(SSL based one : https://) using APS.NET core (System.Net.HttpWebRequest). I need to ignore the certificate error which occurred while getting the WebResponse. I referred…
2
votes
2 answers

Create generic async task function

I have created a function that returns an object using async/await. I would like to make the function generic so that it can return whatever object that I pass in. The code is boilerplate except for the objects being returned. I would like to be…
Joe Riggs
  • 1,312
  • 4
  • 23
  • 48
2
votes
0 answers

System.OutOfMemoryException when uploading a large file (~600MB) using .NET 4.0 & HttpClient

I am getting this error only on my local workstation and prod server. In Dev and Cert it is working fine. local workstation - 20 GB memory, Win 7 64 bit, IIS Express, VS 2013 dev, cert & prod - 8 GB memory , 2008 R2 64 Bit, IIS 7.5 I have a…
2
votes
0 answers

HttpWebRequest get the same response object when it's called in the second time

I am using HttpWebRequest to get webpage source code with POST method. The page needs to be accessed for multiple times with different parameters. When getting response in the second time in a short period, it always return the same response object…
kumo15
  • 21
  • 2
2
votes
1 answer

c# .NET 4.5 HttpWebRequest for portable crossplatforms

I cannot change user agent of HttpWebRequest: HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri); request.Headers[HttpRequestHeader.UserAgent] = "test"; Always throw exception. Someone have idea how solve this?
2
votes
3 answers

Could not install package 'NuGet.Client 3.2.0'

I'm working with RESTful webservice, getting error while adding package "System.Net.Http"; "The 'System.Net.Http 4.0.0' package requires NuGet client version '3.0' or above, but the current NuGet version is '2.8.5.0'. " So, to resolve above error…
2
votes
1 answer

System.InvalidCastException : Unable to cast object of type 'WebProxyWrapper' to type 'System.Net.WebProxy'

In .Net 2.0 the following used to work: HttpWebRequest httpWReq = (HttpWebRequest)WebRequest.Create("http://www.google.com"); WebProxy proxy = (WebProxy) WebRequest.DefaultWebProxy; I'm using .Net 4.5 and now it is returning IWebProxy…
sapbucket
  • 6,795
  • 15
  • 57
  • 94
1
2
3
12 13