Questions tagged [webrequest]

WebRequest is an abstract class in .NET Framework for making requests to URIs (including HTTP, HTTPS, FTP and FILE protocols). Related tags: [httpwebrequest], [ftpwebrequest].

webrequest
Filter by
Sorted by
Tagged with
181 votes
11 answers
452k views

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: https://telematicoprova.agenziadogane....
Kenny Rullo's user avatar
  • 2,527
139 votes
13 answers
173k views

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 ...
Razor's user avatar
  • 17.4k
124 votes
4 answers
209k views

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); ...
Alfred B. Thordarson's user avatar
112 votes
4 answers
265k views

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,...
Brian Sweeney's user avatar
88 votes
2 answers
161k views

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 = (...
h3n's user avatar
  • 5,200
82 votes
2 answers
225k views

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

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 ...
voice's user avatar
  • 1,326
82 votes
3 answers
142k views

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 ...
JK.'s user avatar
  • 21.6k
72 votes
10 answers
71k views

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 ...
Joel's user avatar
  • 16.6k
55 votes
4 answers
82k views

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 ...
Himanshu's user avatar
  • 653
55 votes
7 answers
111k views

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 ...
FryHard's user avatar
  • 10.4k
54 votes
1 answer
69k views

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 ...
TorbenJ's user avatar
  • 4,502
49 votes
4 answers
83k views

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 ...
Hemanshu Bhojak's user avatar
49 votes
10 answers
217k views

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 (...
GR7's user avatar
  • 5,133
47 votes
10 answers
68k views

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 ...
Darbio's user avatar
  • 11.3k
40 votes
4 answers
141k views

How to force WebRequest to send Authorization header during POST

When using WebRequest to send a POST, the Authorization header is not sent with the request even though I have manually set the header and set PreAuthenticate to true, eg: webRequest.Headers["...
chris's user avatar
  • 1,771
36 votes
6 answers
16k views

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 ...
Rob Cooper's user avatar
  • 28.7k
35 votes
7 answers
37k views

Is WebRequest The Right C# Tool For Interacting With Websites?

I'm writing a small tool in C# which will need to send and receive data to/from a website using POST and json formatting. I've never done anything like this before in C# (or any language really) so I'...
user avatar
32 votes
2 answers
66k views

Creating WPF BitmapImage from MemoryStream png, gif

I am having some trouble creating a BitmapImage from a MemoryStream from png and gif bytes obtained from a web request. The bytes seem to be downloaded fine and the BitmapImage object is created ...
Simon Fox's user avatar
  • 10.5k
31 votes
1 answer
35k views

How to Replace WebClient with HttpClient?

I have the following WebClient inside my asp.net mvc web application: using (WebClient wc = new WebClient()) // call the Third Party API to get the account id { string url = currentURL + "...
John John's user avatar
29 votes
3 answers
65k views

C# - How to make a HTTP call

I wanted to make an HTTP call to a website. I just need to hit the URL and dont want to upload or download any data. What is the easiest and fastest way to do it. I tried below code but its slow and ...
Mayur J's user avatar
  • 371
28 votes
4 answers
11k views

HttpWebRequest to URL with dot at the end

when i do a GET with WebRequest.Create("http://abc/test.") i get 404 because according to fiddler the trailing dot gets stripped away by .NET and the web server needs the dot. how can i prevent that ...
user avatar
27 votes
3 answers
56k views

Using HTTP Authentication with a C# WebRequest

I want to make a web request to a page that needs authenticating. How would I go about doing this? I found something that said possibly to use the Credentials property, but I'm not sure how to use it.
The.Anti.9's user avatar
25 votes
4 answers
26k views

Multithreading a large number of web requests in c#

I have an program where I need to create some large number of folders to an external sharepoint site (external meaning I can't use the sharepoint object model). Web requests work well for this, but ...
Terry's user avatar
  • 253
22 votes
5 answers
38k views

How can I do digest authentication with HttpWebRequest?

Various articles (1, 2) I discovered make this look easy enough: WebRequest request = HttpWebRequest.Create(url); var credentialCache = new CredentialCache(); credentialCache.Add( new Uri(url), // ...
Cygon's user avatar
  • 9,512
21 votes
0 answers
16k views

How to properly catch a 404 error in .NET [duplicate]

Possible Duplicate: How can I catch a 404? I would like to know the proper way to catch a 404 error with c# asp.net here is the code I'm using HttpWebRequest request = (HttpWebRequest) ...
Luke101's user avatar
  • 64.1k
20 votes
6 answers
24k views

What makes this HTTPS WebRequest time out even though it works in the browser?

Here's my request: var request = (HttpWebRequest) WebRequest.Create("https://mtgox.com/"); request.CookieContainer = new CookieContainer(); request.AllowAutoRedirect = false; request.Accept = "text/...
enverpex's user avatar
  • 1,100
20 votes
5 answers
111k views

How to use WebRequest to POST some data and read response?

Need to have the server make a POST to an API, how do I add POST values to a WebRequest object and how do I send it and get the response (it will be a string) out? I need to POST TWO values, and ...
MetaGuru's user avatar
  • 43.3k
20 votes
5 answers
55k views

Starting async method as Thread or as Task

I'm new to C#s await/async and currently playing around a bit. In my scenario I have a simple client-object which has a WebRequest property. The client should send periodically alive-messages over ...
KingKerosin's user avatar
  • 3,727
20 votes
6 answers
4k views

How to calculate HttpWebRequest spent outbound and inbound internet traffic

I have the below function to fetch a page. My question is i want to calculate how much internet connection is spent Both inbound (download) and outbound traffic (sent) How can i do that ? Thank you ...
Furkan Gözükara's user avatar
19 votes
4 answers
26k views

"too many automatic redirections were attempted" error message when using a httpWebRequest in .NET

I am attempting to request a page like "http://www.google.com/?q=random" using the webrequest class in vb.net. we are behind a firewall, so we have to authenticate our requests. I have gotten past the ...
tooleb's user avatar
  • 612
19 votes
2 answers
20k views

how to change originating IP in HttpWebRequest

I'm running this application on a server that has assigned 5 IPs. I use HttpWebRequest to fetch some data from a website. But when I make the connection I have be able to specify which one of the 5 ...
Tudor Carean's user avatar
19 votes
4 answers
34k views

Reading data from an open HTTP stream

I am trying to use the .NET WebRequest/WebResponse classes to access the Twitter streaming API here "http://stream.twitter.com/spritzer.json". I need to be able to open the connection and read data ...
user108687's user avatar
18 votes
3 answers
29k views

How to get website title from c#

I'm revisiting som old code of mine and have stumbled upon a method for getting the title of a website based on its url. It's not really what you would call a stable method as it often fails to ...
Morten Christiansen's user avatar
18 votes
3 answers
30k views

Does any one know about this error: "Wrong Local header signature: 0x6D74683C"?

The following code is used to download a zip file and unzip it on phone. The same code used to work on WP7, I started tested on WP8 device, and strange thing is happening... now it works on WP8 but ...
wafers's user avatar
  • 1,189
18 votes
2 answers
2k views

Bandwidth Shaping in my C# application

I have a C# application that uses a native library that sends video to other IP over the internet using UDP. I have no traffic control over that library. My application also calls web services of ...
Matin Lotfaliee's user avatar
17 votes
1 answer
23k views

powershell curl and WebRequest both follow redirects

I was trying to figure out the status code returned by my webpage, which most certainly is 301 (moved permanently), according to curl on the Linux subsystem, but using curl or the WebRequest object on ...
bluppfisk's user avatar
  • 2,561
17 votes
3 answers
28k views

System.Net.ProtocolViolationException: You must write ContentLength bytes to the request stream before calling [Begin]GetResponse

I am getting the "System.Net.ProtocolViolationException: You must write ContentLength bytes to the request stream before calling [Begin]GetResponse" error when calling to the "BeginGetResponse" ...
user3815821's user avatar
16 votes
3 answers
56k views

How to set User Agent with System.Net.WebRequest in c#

I'm trying to set User Agent with WebRequest, but unfortunately, I've only found how to do it using HttpWebRequest, so here is my code and I hope you can help me to set the User-Agent using WebRequest....
enb141's user avatar
  • 166
16 votes
5 answers
13k views

Get unique worker/thread/process/request ID in PHP

In multi-threaded environments (like most web platforms) I often include some sort of thread ID to the logs of my apps. This enables me to tell exactly what log entry came from which request/thread, ...
Jonas Sourlier's user avatar
16 votes
4 answers
32k views

PowerShell v3 Invoke-WebRequest: Troubles with forms

Since I upgraded to Windows 8 a lot of my PowerShell scripts relying on launching an invisible IE won’t quite work anymore, so I tried switching to the Invoke-WebRequest command. I did a lot of ...
Phil Strahl's user avatar
16 votes
5 answers
11k views

Sending gzipped data in WebRequest?

I have a large amount of data (~100k) that my C# app is sending to my Apache server with mod_gzip installed. I'm attempting to gzip the data first using System.IO.Compression.GZipStream. PHP receives ...
user avatar
16 votes
4 answers
5k views

WebRequest fails to download large files (~ 1 GB) properly

I am attempting to download a large file from a public URL. It seemed to work fine at first but 1 / 10 computers seem to timeout. My initial attempt was to use WebClient.DownloadFileAsync but because ...
Spish's user avatar
  • 513
15 votes
4 answers
40k views

Downloading pdf file using WebRequests

I'm trying to download a number of pdf files automagically given a list of urls. Here's the code I have: HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.Method = "GET"; ...
Aabela's user avatar
  • 1,408
15 votes
2 answers
63k views

Using WebClient or WebRequest to login to a website and access data

I'm trying to access restricted data on a website using WebClient/WebRequest. There is no official API in that website, so what I'm trying to do is simply fill the HTML form and post the values to the ...
Shimmy Weitzhandler's user avatar
15 votes
2 answers
20k views

chrome.webRequest.onBeforeRequest.addListener Cannot read property 'onBeforeRequest' of undefined

I'm trying to build my own chrome extension and I'm trying to add an event handler using onBeforeRequest. My manifest.json: { "manifest_version": 2, "name": "My extension", "description"...
user avatar
14 votes
3 answers
23k views

Can I send webrequest from specified ip address with .NET Framework?

I have a server with multi ip addresses. Now I need to communicate with several servers with http protocol. Each server only accept the request from a specified ip address of my server. But when using ...
唐英荣's user avatar
  • 315
13 votes
1 answer
33k views

Getting full response body from System.Net.WebRequest

I'm using System.Net.WebRequest to get info from some API. When I get an error, the response contains only the basic HttpStatusCode and message, and not the full error returned. For comparison, ...
AlexD's user avatar
  • 4,230
12 votes
2 answers
42k views

C# Getting proxy settings from Internet Explorer

i have a problem in certain company in germany. They use proxy in their network and my program cant communicate with server. IE works with this settings: It means: Automatically detect settings ...
Kaminari's user avatar
  • 1,487
12 votes
2 answers
13k views

HttpWebRequest or WebRequest - Resume Download ASP.NET

I would like to know if there is a way to know if a server supports resume download functionallity and if supported, how do I send a request to resume? I was looking for a solution where my ASP.NET ...
Cleiton's user avatar
  • 17.9k
12 votes
4 answers
25k views

How to send a POST with a JSON in a WebRequest() call using MQL4?

I would like to send a POST from MQL4-script, using a JSON-format to a Node-server. I've tried the webRequest() standard function in MQL4, based on the following documentation, but it did NOT success....
koul's user avatar
  • 461

1
2 3 4 5
33