httpwebrequest

How to read the data returned from WebRequest in asp.net ?

Hi, I am trying to integrate 3D Secure to my customer's e-shop. I need to post some data to 3DGate and get the returned result from it. I have used WebRequest for this, i have posted the data successfuly but the returned data is an Html Text which has a form in it and some inputs in the form. I need to read these values like Request.Fo...

.Net HttpWebRequest.GetResponse() raises exception when http status code 400 (bad request) is returned

I am in a situation where when I get an HTTP 400 code from the server, it is a completely legal way of the server telling me what was wrong with my request (using a message in the HTTP response content) However, the .NET HttpWebRequest raises an exception when the status code is 400. How do I handle this? For me a 400 is completely le...

Server benchmarking: how many http requests can the server process?

I am creating an application which sends the measurement data every 200 ms from mobile phone to the server. The data have to be processed in real-time, but I noticed that the difference between the sent time and the time of process start is getting bigger and bigger so I have to find the point where the the requests get stuck. I am send...

Invoking a POST to an external site with C# (httpwebrequest)

This is driving me nuts and I can't figure out where I am dropping the ball. I've followed a few examples found via the googlemonsta to no avail. Any pointer to where I goofed would be greatly apperciated. var writer = new StringWriter(); param = "location=" + Server.UrlEncode(param); byte[] paramStream = Encodin...

c# simple HttpWebRequest question

The following code fails with a 400 bad request exception. My network connection is good and I can go to the site but I cannot get this uri with HttpWebRequest. Any help is appreciated! private void button3_Click(object sender, EventArgs e) { WebRequest req = HttpWebRequest.Create(@"http://www.youtube.com/")...

How to use HttpWebRequest to call a Web Service Operation that takes in a byte[] parameter?

Hi guys I am trying to call a [webmethod] from C#. I can call simple webmethod that take in 'string' parameters. But I have a webmethod that takes in a 'byte[]' parameter. I am running into '500 internal server error' when I try to call it. Here is some example of what I am doing. Lets say my method is like this [WebMethod] publ...

C# Xml in Http Post Request Message Body

Hello, I am looking for an example of how, in C#, to put a xml document in the message body of a http request and then parse the response. I've read the documentation but I would just like to see an example if there's one available. Does anyone have a example? thanks ...

Is there a correct way to dispose of a httpwebrequest?

I am using a httpwebrequest, and am disposing of the response stream. Is there a correct method of disposing of the httpwebrequest, as it does not contain a close or dispose method? ...

Authentication headers not sending in HttpWebRequest

I am connecting to a service using a HttpWebRequest. In the service logs, there are Authentication errors being logged, even though the information is correct. The vendor who set up the server with the service, has said that .NET does not send the authentication headers on the first try. _Req.Credentials = new NetworkCredential(usernam...

Request for several responses

Hi Guys, I would like to create a web application. There are cases, when a user's request would result in refreshing the content in 2-3 or sometimes even more containers. The cleanest way would be to run the requests one after the other in a sequence and handle the results one by one. I would like to have only one request if it is poss...

How to mix compression and caching in HttpWebRequest?

I have a c# client talking to a cherrypy(http/rest) webservice. The problem is i can't both turn on compression and caching at the same time. request.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate; By leaving out the above line I get the correct caching headers (If-None-Math,If-Modified-Since) while ...

Keep a http connection alive in C#?

How do i keep a connection alive in C#? I'm not doing it right. Am i suppose to create an HttpWebRequest obj and use it to go to any URLs i need? i dont see a way to visit a url other then the HttpWebRequest.Create static method. How do i create a connection, keep it alive, browse multiple pages/media on the page and support proxys? (i ...

Request a 2nd url with the same HttpWebRequest obj

I want to do something like this { HttpWebRequest WebRequestObject = (HttpWebRequest)HttpWebRequest.Create("http://google.com"); WebRequestObject.KeepAlive = true; //do stuff WebRequestObject.Something("http://www.google.com/intl/en_ALL/images/logo.gif"); //more here } How do i keep the connection alive and go to m...

HttpWebRequest one proxy and one not

How do i proxy my connections? i want 3 default HttpWebRequest objs that will not go through a proxy and another 3 that does. Do i do WebRequestObject.Proxy = myProxy; on objects i want to use a proxy on and do nothing on the 3 objs i do not? also the objects will initialize in an unknown order so i may have 2 not, 2 that is proxied, a 3...

WebRequest and System.Net.WebException on 404, slow?

I am using a WebRequest to check if a web page or media (image) exist. On GetResponse i get a System.Net.WebException exception. I ran through 100 links and it feels like its going slower then it should. Is there a way to not get this exception or handle this more gracefully? static public bool CheckExist(string url) { H...

WebRequest get page w/o exceptions?

I want to check the status of a page (404, moved, etc). How can i do it? ATM i am doing the below which only tells me if the page exist or not. Also, i suspect the exception is making my code slow (i tested it) static public bool CheckExist(string url) { HttpWebRequest wreq = null; HttpWebResponse wresp =...

Why is this WebRequest code slow?

I requested 100 pages that all 404. I wrote { var s = DateTime.Now; for(int i=0; i < 100;i++) DL.CheckExist("http://google.com/lol" + i.ToString() + ".jpg"); var e = DateTime.Now; var d = e-s; d=d; Console.WriteLine(d); } static public bool CheckExist(string url) { HttpWebRequest wreq...

The system is experiencing problem that requested for support

HI, We created a web application which is running in many web servers. One of the server was recently updated. When they request the web page which usually streaming PDF content, the alert message displayed and return back to last page visited. The alert message has the title: Windows Internet Explorer Alert message is "The System is ...

Where to write XML with XmlWriter for sending via HttpWebRequest POST in ASP.NET?

Here is my code, see the part that says ???WHAT TO DO HERE??? I am not sure where I write this XML to in order to be able to send it in my POST via the objRequest there... string project_id = context.Request.QueryString["project"]; string person_id = context.Request.QueryString["person"]; string post_date = context.Request.QueryString["...

Amount of Connections per server? C#, web

I am connecting to a 3rd party server. I know right now they allow 8 connections from the same remote user. However i dont know if they will raise or lower the connection limit. So i want my app to dynamically find out. How can i do this? I'm using C#, MSVS 2008 I started a bounty for anyone who can give me working C#. If no one does t...