Questions tagged [system.net.httpwebrequest]

1

votes
0

answer
58

Views

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 out so far: -requests work fine in a console app -r...
germanraona
1

votes
0

answer
100

Views

Screen Scraping using WebResponse

In my asp.net based application, I am reading a WebResponse by invoking a Http WebRequest to another aspx page. The response contains a table (Gridview used in actual page) with a td column(among other td columns) containing an anchor element. On click of the anchor call to download the relevant fil...
Justin Samuel
1

votes
0

answer
19

Views

Break point not working in Script Component if the Sytem.Net.Http DLL is added as reference for the code

I am finding very difficult to debug the code because the break-point is not working in Script component inside Data Flow Task. If I run the code after inserting break-point, it doesn't stop at the break point and gets overridden. I thought it was Visual Studio issue as I had downgraded to previou...
Sharan G
0

votes
0

answer
5

Views

403 Forbidden making a POST after GET with same CSRF Token

First method: Get the CSRF token string from an GET_API_URL. This works fine. Second method: Make a POST to POST_API_URL with the obtained CSRF string. Problem is, no matter what I tried, it kept getting 403 Forbidden error. Have tried storing first response's cookies (3 cookies - 2 are secure) int...
atang
1

votes
2

answer
715

Views

Anonymous HTTP Web Request

I created http request application to test my web site qulatiy (see below). Dim Request As HttpWebRequest = WebRequest.Create(webAddress) Dim Response As HttpWebResponse = Request.GetResponse() Request.Method = 'Get' Dim Reader As New StreamReader(Response.GetResponseStream) Dim Html As String = Rea...
zanhtet
1

votes
1

answer
1.3k

Views

Sending a file via WebRequest

I need to use C# to send a file to with the content-type of application/octet stream. I can create an HttpWebRequest like the below: HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create('http://test.com'); request.Headers.Add('content-type', 'application/octet-stream'); //Add file here? Ht...
steventnorris
1

votes
1

answer
164

Views

Spreedly authentication error using C#.Net HttpWebRequest: “You must specify an environment_key parameter”

I'm currently working with Spreedly REST API which works with basic http authentication. At first, I set my credentials this way: webRequest.Credentials = new System.Net.NetworkCredential(user, password); It worked well for many of the API resources including POSTing new gateways, GETing gateways, P...
Peter Perron
1

votes
1

answer
246

Views

.Net Windows webBrowser - how to extract authorization header from webBrowser response and send to another consecutive request?

I have a windows desktop application. I need to open SSO login page in windows application. For this, I am using windows web browser control to open SSO login page. Once successfully logged-in, I need to get Authorization header from SSO login and use this authorization token for consecutive REST ca...
Ashok
1

votes
2

answer
206

Views

Xamarin Http Requests only work on iOS Simulator

I am using system.net.http to build a web service layer for my app. I started building this on an iphone simulator (as I develop for iOS first) and everything is working. I checked in my code and then started testing on other devices and nothing works... I get the same exception on a physical iOS de...
Bodungus
1

votes
1

answer
994

Views

Why were constructors for HttpWebRequest and HttpWebResponse removed from .NET?

Perhaps it doesn't make sense for product code to instantiate these types but the deprecation of the constuctors has made unit testing clients which use the Http implementations of WebRequest/Response far more trouble than it should be. I see no value in taking the constructors away and obvious valu...
evanmcdonnal
1

votes
1

answer
1.7k

Views

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 instead of WebProxy. How can I cast it to be WebProxy instead of...
sapbucket
1

votes
1

answer
8.6k

Views

Getting “Unable to connect to a remote server” error while calling a service from Web Application

I am getting 'Unable to connect to a remote server' error while calling a service using Web Application. But the same code runs when I call it from a console application. I just have the URL of the service. Here is the stack trace: at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot,...
Sumit
2

votes
3

answer
1.2k

Views

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 i'm trying to install 'NuGet client' from 'Add Packag...
priyanka kamthe
6

votes
1

answer
7.3k

Views

Web Api: System.Net.Http version 2.0.0.0 not found

When I install the NuGet package for WebApi, it gives me version 1.0.0.0 of System.Net.Http, yet it references version 2. I cannot seem to find version 2 for the life of me. When I download .net 4.5 I get System.Net.Http version 4.0.315.x, but I cannot use that because the Web Api assemblies refer t...
CDubbz31
5

votes
1

answer
2.3k

Views

What's the alternative to WebRequestHandler in .NET Core?

I was using the WebRequestHandler for setting the CachePolicy and AuthenticationLevel in my full stack .NET application. Now I am migrating my application to .NET core and can't find an alternative to these properties or the WebRequestHandler. Any help? Following is my usage: var httpClientHandler =...
Amit
2

votes
2

answer
1.7k

Views

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 able to call GetAsync and have it return the correct o...
jriggs
3

votes
2

answer
392

Views

In c#( .net) system.net.http, how to get the response.statuscode as an int? Not to use HttpWebRequest and HttpWebResponse

var hcHandler = new HttpClientHandler(); //hcHandler.AllowAutoRedirect = false; var hc = new HttpClient(hcHandler); hc.DefaultRequestHeaders.Add('user-agent', 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)'); String url = 'http://passport.cnblogs.com/login.aspx'; var task =...
陈黎栋John
7

votes
1

answer
5.2k

Views

HttpResponseMessage unavailable in App_Code folder of VS 2012 project

I am writing a Web API project (MVC architecture). I have a utility class with methods that returns an HttpResponseMessage. If this class is placed in a Utility folder everything works. If I attempt to place the class within the App_Code folder, I receive the message 'The type or namespace name '...
Lee Z
2

votes
0

answer
302

Views

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 to me. After debugging, if the second call is after...
kumo15
2

votes
1

answer
911

Views

WebRequest.GetResponse() Times Out After A Couple of Requests

I'm calling a third party web API to update some of our data on their side. I've been submitting about five jobs in quick succession and, without fail, the first two requests are working properly. The last three however never update. The application seems to be indicating that the request is timing...
elucid8
1

votes
1

answer
7.2k

Views

How do I carry a cookie from a System.Net.HttpWebResponse to the next System.Net.HttpWebRequest?

I'm trying to do some automated web requests and need to maintain a cookie from one to the next. I can see that I'm getting back the cookie I want from the initial response, but I can't attach it to the next request. c# code // response part using (var wresp = (System.Net.HttpWebResponse)wrequest.Ge...
lincolnk
1

votes
1

answer
729

Views

Visual Studio Team Services API Example Throwing System.Net.Http Error

I'm trying to write an application that communicates with Visual Studio Team Services, using the Nuget packages listed here. The example code is directly from Microsoft's official documentation, on same same page the packages are listed, under 'Pattern for use'. My test code is in a console applica...
Bradley Uffner
6

votes
3

answer
184

Views

FileNotFoundException: Could not load file or assembly 'System.Net.Http.WebRequest'

I've downloaded the latest .NET Framework and I'm working on .NET Core 2.0 Application on VS 2017 15.8.7. Here are the packages I've installed. using (var client = new PowerBIClient(new Uri(ApiUrl), tokenCredentials)) { } I'm getting an error at this line, saying: FileNotFoundException: Could not lo...
MAK
4

votes
1

answer
9.4k

Views

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 proxy URI as a string? HttpWebRequest webRequest =...
Paul Matthews
2

votes
1

answer
4.5k

Views

C# System.Net.WebRequest HTTP Request Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host

Before I get started First let me apologize in advance if this is a duplicate question as there appear to be several questions related to 'Existing connection was forcible closed by the remote host', however I can't seem to get any help from these other questions as they same to be either related to...
pat8719
4

votes
2

answer
3.6k

Views

Open Html code in browser

i have a c# application, which calls an API and the response is in HTML format. i don't want to save the HTML code to a file but i want to open that html code in a browser i am able to display if the HTML is saved in a file using System.Diagnostics.Process.Start(pathToHtmlFile);
Sumeshk
1

votes
4

answer
6k

Views

How to Skip HttpWebResponse 404

Hi i have a program thats looking on some pages for (int i=1; i < 1000; i++) { string id = i.ToString(); string url_source = get_url_source('http://mysite.com/'+id); } and a method public static string get_url_source(string url) { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); Http...
Incognito
5

votes
2

answer
3.1k

Views

Establishing SSL\TLS connection (X509Chain.Build()) takes too long

I found that when I use HttpWebRequest to establish SSL\TLS connection, it takes near 30s when calling request.GetRequestStream() when I've enabled tracing with stacktrace enabled, I found that 2s goes to find poxy, so I've disabled it in app.config: Next point that takes near 28s was in at System.N...
hkurabko
2

votes
2

answer
1.1k

Views

send httprequest in order to receive some data

I have some difficulties in requesting an access token from an other server. A request to get that is: POST /auth/O2/token HTTP/1.1 Host: api.amazon.com Content-Type: application/x-www-form-urlencoded;charset=UTF-8 grant_type=client_credentials&scope=messaging:push&client_id=(YOUR_CLIENT_ID)&client_...
mouhcine
1

votes
3

answer
5k

Views

GetResponseStream() or ReadBytes() who is actually responsible for downloading the data and how?

If we create a HttpWebRequest and get the ResponseStream from its response, then whether the data will get downloaded completely at once or, when we call the ReadBytes of the stream , then only the data will get download from the network and then reads the content? Code sample which i want to refer...
Manish Rawat
2

votes
1

answer
317

Views

HttpWebRequest force new connection

I want to download large file from limited-transfer server using several threads with HttpWebRequest.AddRange(int, int). The problem is that all my threads but one get blocked on GetResponse(), probably becouse they want to reuse the connection of the first thread. I've set the KeepAlive property of...
noisy cat
2

votes
2

answer
2.8k

Views

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 many blogs and got a solution of using ServicePointMan...
Clinton Prakash
6

votes
1

answer
2.9k

Views

Using GoogleApisClient ServiceAccountCredential calling RequestAccessTokenAsync throws Exception

Background: I have set up a Service Account for my project on Google Developer Console and using the Service Account Email, the Certificate and the secret password and following the example provide in the GoogleAPisSample Plus.ServiceAccount. The snippet below is part of my Windows Service applicati...
user3254653
4

votes
1

answer
6.1k

Views

Getting “Stream not readable” when reading HttpWebResponse

I'm trying to 'screen scrape' some data I have a request as follows (from fiddler) POST http://fallenlondon.storynexus.com/Auth/EmailLogin HTTP/1.1 Content-Type: application/x-www-form-urlencoded Referer: http://fallenlondon.storynexus.com/signup User-Agent: Mine Accept: text/html,application/xhtml+...
Taoist
3

votes
0

answer
227

Views

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 I am downloading with C# code from...
Lucian Chiriac
3

votes
3

answer
8.9k

Views

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 = cookieJar, AllowAutoRedirect = true }; handler.UseCookies = true; handler.UseDefaultCre...
silverfighter
3

votes
1

answer
824

Views

Get body text from an HttpWebRequest object?

I have a (legacy) method in my codebase which generates and returns a ready-to-send HTTP POST message as a System.Net.HttpWebRequest object: public HttpWebRequest GetHttpWebRequest(string body, string url, string contentType) { HttpWebRequest request = HttpWebRequest.CreateHttp(url); request.Method...
Jon Schneider
2

votes
0

answer
623

Views

HttpWebResponse displays siteminder login even though URLs are configured to be by passed in Siteminder

I am stumped on this problem and have come humbled to the experts on advice for my problem. I have an ASP.NET MVC app that is Siteminder enabled. In addition, this app has a section of URLS that are web services which provide data to another application. Those URLS have been configured for 'bypass'...
James Waters
3

votes
2

answer
2.1k

Views

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 { private static readonly List _requests = new List(); priv...
jjdev80
2

votes
2

answer
559

Views

How to deserialize a JSON response with list of objects with variable name starting with _ or $

How to deserialize the web response like this: [{'_exp':'2014-06-05T23:58:03.859Z','_id':'123','$val':'dabg'}, {'_exp':'2014-07-05T23:58:03.859Z','_id':'143','$val':'dabg'}] Here my specific question is that I am not able to create a response class having the variable name starting with $ as C# doe...
user3904654

View additional questions