Questions tagged [webrequest]

WebRequest is a abstract class in .NET Framework for making requests to URIs (including HTTP, HTTPS, FTP and FILE protocols).

WebRequest is a abstract class in .NET Framework for making requests to URIs (including HTTP, HTTPS, FTP and FILE protocols).

1519 questions
154
votes
10 answers

HttpWebRequest using Basic authentication

I'm trying to go through an authentication request that mimics the "basic auth request" we're used to seeing when setting up IIS for this behavior. The URL is:…
Kenny Rullo
  • 2,157
  • 2
  • 14
  • 7
135
votes
12 answers

Cannot set some HTTP headers when using System.Net.WebRequest

When I try to add a HTTP header key/value pair on a WebRequest object, I get the following exception: This header must be modified using the appropriate property I've tried adding new values to the Headers collection by using the Add() method but…
Razor
  • 16,811
  • 22
  • 87
  • 137
119
votes
4 answers

How do I use WebRequest to access an SSL encrypted site using HTTPS?

I'm writing a program that reads content from a user provided URL. My problem is in the code that goes something like this: Uri uri = new Uri(url); WebRequest webRequest = WebRequest.Create(uri); WebResponse webResponse =…
Alfred B. Thordarson
  • 4,280
  • 8
  • 36
  • 37
99
votes
4 answers

Cannot send a content-body with this verb-type

I just got this exception (ProtocolViolationException) in my .NET 2.0 app (running on windows mobile 6 standard emulator). What confuses me is that as far as i know, I have not added any content body, unless I've inadvertently done it somehow. My…
Brian Sweeney
  • 6,415
  • 12
  • 50
  • 68
82
votes
2 answers

How to get json response using system.net.webrequest in c#?

I need to get json data from an external domain. I used webrequest to get the response from a website. Here's the code: var request = WebRequest.Create(url); string text; var response = (HttpWebResponse) request.GetResponse(); using (var sr = new…
h3n
  • 4,786
  • 9
  • 40
  • 70
81
votes
3 answers

Which versions of SSL/TLS does System.Net.WebRequest support?

Now that SSL 3 has been found to be vulnerable to the POODLE attack: Which versions of SSL/TLS does System.Net.WebRequest use when connecting to any https Uri? I use WebRequest to connect to several 3rd party API's. One of these has now said they…
JK.
  • 20,010
  • 29
  • 124
  • 204
76
votes
2 answers

How do you send an HTTP Get Web Request in Python?

I am having trouble sending data to a website and getting a response in Python. I have seen similar questions, but none of them seem to accomplish what I am aiming for. This is my C# code I'm trying to port to Python: static void Request(Uri…
LeChosenOne
  • 1,266
  • 1
  • 11
  • 16
71
votes
10 answers

Mono https webrequest fails with "The authentication or decryption has failed"

I'm making a simple REST client to use in my C# applications. In .net on Windows It works great with http:// and https:// connections. In mono 2.6.7 (Also tested with 2.8 with the same results) on Ubuntu 10.10 only http:// works. https://…
Joel
  • 15,576
  • 16
  • 69
  • 92
52
votes
4 answers

Forcing Basic Authentication in WebRequest

I am integrating web service that will use an HTTP-POST to request and retrieve data. The remote server requires basic authentication as per RFC 2617 My attempts to authenticate are failing. It fails in that, even though I attach a…
Himanshu
  • 623
  • 1
  • 5
  • 7
52
votes
7 answers

Test if a website is alive from a C# application

I am looking for the best way to test if a website is alive from a C# application. Background My application consists of a Winforms UI, a backend WCF service and a website to publish content to the UI and other consumers. To prevent the situation…
FryHard
  • 9,690
  • 7
  • 32
  • 37
51
votes
1 answer

HttpWebRequest: Add Cookie to CookieContainer -> ArgumentException (Parametername: cookie.Domain)

I'm trying to login to a website via my application. What I did: First I figured out how the browser does the authorization process with Fiddler. I examined how the POST request is built and I tried to reconstruct it. The browser sends 4 cookies…
TorbenJ
  • 4,110
  • 9
  • 41
  • 77
46
votes
8 answers

HttpWebRequest times out on second call

Why does the following code Timeout the second (and subsequent) time it is run? The code hangs at: using (Stream objStream = request.GetResponse().GetResponseStream()) and then causes a WebException saying that the request has timed out. I have…
Darbio
  • 10,681
  • 12
  • 55
  • 98
44
votes
4 answers

Making a web request to a web page which requires windows authentication

I am trying to make a request to a web page using WebRequest class in .net. The url that I am trying to read requires Windows Authentication due to which I get an unauthorised exception. How can I pass a windows credentials to this request so that…
Hemanshu Bhojak
  • 15,934
  • 15
  • 46
  • 60
36
votes
5 answers

Mocking WebResponse's from a WebRequest

I have finally started messing around with creating some apps that work with RESTful web interfaces, however, I am concerned that I am hammering their servers every time I hit F5 to run a series of tests.. Basically, I need to get a series of web…
Rob Cooper
  • 27,684
  • 25
  • 100
  • 142
36
votes
9 answers

Reasons for a 409/Conflict HTTP error when uploading a file to sharepoint using a .NET WebRequest?

I've got a method that uses a WebRequest to upload a file to a sharepoint 2010 list/folder, using a PUT request, with the Overwrite Header set to T (overwrite). When several files are uploaded (method is called several times), some requests fail…
GR7
  • 4,713
  • 7
  • 45
  • 60
1
2 3
99 100