httpwebrequest

DNS HTTP Requests

If I was to send a URL to a DNS server, lets say: "dev.example.com/?username=daniel", what is exactly sent to the DNS server? The whole URL (including any passed parameters) or is it just website section "dev.example.com"? I want to know so that I know what parameters I should be hiding in a URL. The reason I am asking is because I jus...

cURL changing the URL after POST

I am doing an HTTP POST using cURL $url = "http://localhost:8080/~demo/cgi-bin/execute/100"; //open connection $ch = curl_init(); //set the url, number of POST vars, POST data curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch,CURLOPT_POST,count($data)); curl_setopt($ch,CURLOPT_POSTFIELDS,$data); //execute post $result = curl_exec($c...

Relative filepath with HttpWebRequest object

Hi, I am trying to create unittests that can be shared amongst my development team so I need to have all paths in the project be relative. Where this is giving me trouble is with the HttpWebRequest class. I want it to serve static testdata from a file in the local filesystem. I'd like to do something like this: file:///./TestData/te...

How do i make a http get request with parameters in c#

Hi Is it possible to pass parameters with a http get request if so how should I then do it. I have found a http post requst http://msdn.microsoft.com/en-us/library/debx8sh9.aspx it that example the string postData is send to a webserver, I would like to do the same using GET instead. Google found this example on http get http://support....

C# httpwebrequest and javascript

Hi all. I am using C# HttpWebRequest to get some data of a webpage. The problem is that some of the data is updated using javascript/ajax after the page is loaded and I am not getting it in the response string. Is there a way to have the webrequest wait untill all the scripts in the page have finished executing? Thanks Amit ...

How do i get detailed info from a HttpWebResponse

Hi I'm making a post httpwebrequst, but in the HttpWebResponse im getting an error code 403 forbidden. Now that error isnt very use full to me. I then tried a testprogram (that i do not have the source code to :() and used it to make the same post, and it returned with a code 403 forbidden but also told me tha SSL was needed. So is it...

"too many automatic redirections were attempted" error message when using a httpWebRequest in VB.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 authentication part by adding my credentials. But once that works it seems to go into a redirecting loop. Does anyone have an ideas, comm...

Is it possible to change headers order using HttpWebRequest?

I need to change the order of headers, I'm using this: HttpWebRequest request = (HttpWebRequest)WebRequest.Create(URL); request.Method = context.Request.HttpMethod; request.UserAgent = context.Request.UserAgent; The output for that is: GET /* HTTP/1.1 User-Agent: My Server Host: 127.0.0.1:1080 But it should be GET /* HTTP/1.1 Host...

Sockets in C#: How to get the response stream?

Hi I'm trying to replace this: void ProcessRequest(object listenerContext) { var context = (HttpListenerContext)listenerContext; Uri URL = new Uri(context.Request.RawUrl); HttpWebRequest.DefaultWebProxy = null; HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(URL); httpWebRequest.Method = context.Re...

Using a self-signed certificate with .NET's HttpWebRequest/Response

I'm trying to connect to an API that uses a self-signed SSL certificate. I'm doing so using .NET's HttpWebRequest and HttpWebResponse objects. And I'm getting an exception that: The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel. I understand what this means. And I understand...

How to clear the cache of HttpWebRequest

I am developing against a proprietary library and are experiencing some issues with the cache of the HttpWebRequest. The library is using code equivalent to below to make requests: var request = WebRequest.Create("http://example.com/") as HttpWebRequest; request.CachePolicy = new HttpRequestCachePolicy(HttpRequestCacheLevel.CacheIfAvai...

HttpWebRequest with https in C#

This piece of code doesn't work; it's logging in into website which is using https protocol. How to solve this problem? The code stops at "GetRequestStream()" anytime anywhere saying that protocol violation exception is unhandled.. string username = "user"; string password = "pass"; HttpWebRequest request = (HttpWebRequest)WebRequest.Cr...

How to keep logged instance (httpwebrequest) alive and query another page with it?

Hi, After I've succesfully logged into website using POST variables by httpwebrequest and got response by HttpWebResponse ..How do I query other websites with the "current logged in" instance? Do I save it to some variable?? ...

How to insert CookieCollection to CookieContainer?

Hi, After I get response from httpwebrequest, I'd like the cookies obtained to save for the purpose of using them in another httbwebrequest. However, I'd need to insert CookieCollection to CookieContainer. How do I do that? Tried to do: request.Cookiecontainer.add(response.Cookies); but this keeps getting out of error: Object referen...

Internal vs External CSS

Hi, What's the pro's and con's on Internal vs External CSS, thinking of speed, requests, caching etc..? Personally I'm not sure if internal css on dynamic pages will cache..? ...

HttpWebRequest timeout in 3.5sp1

We have a service that opens several HttpWebRequests. It ran fine under 3.0 until we upgraded the server to .net 3.5sp1. Now we get timeouts while waiting for the request. (we have verified that the endpoint is up and running). There are a few things that make this interesting. Increasing the number of max connections will let it ru...

Stopping an Async HttpWebRequest

I have an application that makes several concurrent requests to a web resource using HttpWebRequest asynchronously. Even though I've set the timeout property of my HttpWebRequest instance to say 5 seconds, sometimes when async calling BeginGetRequestStream, getting the stream can take much longer than that and is causing quote a mess for...

HTTP POST Returns The Error: 417 "Expectation Failed." (C#) (RESOLVED)

Hi. I'm trying to login to a website using HTTP POST method. I've inspected and altered the POST data while logging in to the website and I came to the conclusion that only the two "username" and "password" fields are required to be passed as POST data to the login page, I removed all other headers namely user-agent, Referer etc and stil...

Upload files with HTTPWebrequest (multipart/form-data)

Is there any class, library or some piece of code which will help me to upload files with HTTPWebrequest? Edit 2: I do not want to upload to a WebDAV folder or something like that. I want to simulate a browser, so just like you upload your avatar to a forum or upload a file via form in a web application. Upload to a form which uses a ...

Object reference not set to an instance of an object

I am seeing following exception. System.NullReferenceException: Object reference not set to an instance of an object. at System.Web.Util.StringUtil.memcpyimpl(Byte* src, Byte* dest, Int32 len) at System.Web.Util.StringUtil.UnsafeStringCopy(String src, Int32 srcIndex, Char[] dest, Int32 destIndex, Int32 len) at System.Web.HttpW...