webrequest

Using .NET to Post a file to Server HttpWebRequest or WebClient

拜拜、爱过 提交于 2019-12-01 00:53:25
问题 Okay so here is the deal. As the question states, I'm trying to POST a file to a webserver and am having a few issues. I've tried posting this same file to the same webserver using Curl.exe and have had no issues. I've posted the flags I used with curl just incase they might point out any potential reasons why I'm having trouble with the .NET classes. curl.exe --user "myUser:myPass" --header "Content-Type: application/gzip" --data-binary "@filename.txt.gz" --cookie "data=service; data-ver=2;

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

梦想的初衷 提交于 2019-11-30 22:21:00
问题 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" method of the web request. This is my code: try { Stream dataStream = null; WebRequest Webrequest; Webrequest = WebRequest.Create(this.EndPointAddress); Webrequest.Credentials = new NetworkCredential(this.username, this.password); Webrequest.ContentType = "text/xml"; Webrequest.Method =

MonoTouch - WebRequest memory leak and crash?

坚强是说给别人听的谎言 提交于 2019-11-30 21:41:24
I've got a MonoTouch app that does an HTTP POST with a 3.5MB file, and it is very unstable on the primary platforms that I test on (iPhone 3G with OS 3.1.2 and iPhone 4 with OS 4.2.1). I'll describe what I'm doing here and maybe someone can tell me if I'm doing something wrong. In order to rule out the rest of my app, I've whittled this down to a tiny sample app. The app is an iPhone OpenGL Project and it does only this: At startup, allocate 6MB of memory in 30k chunks. This simulates my app's memory usage. Read a 3.5MB file into memory. Create a thread to post the data. (Make a WebRequest

PowerShell v3 Invoke-WebRequest: Troubles with forms

妖精的绣舞 提交于 2019-11-30 17:32:37
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 googling but still can’t get my script to work. This is what it should do: load up a website with a simple form (username, password, submit-button), enter the credentials and submit them. With the "help" of the incredibly bad Microsoft tech-net examples (at least for me), I pieced the following together: $myUrl = "http://some.url" $response = Invoke-WebRequest -Uri $myUrl -Method Default

MonoTouch - WebRequest memory leak and crash?

送分小仙女□ 提交于 2019-11-30 17:11:47
问题 I've got a MonoTouch app that does an HTTP POST with a 3.5MB file, and it is very unstable on the primary platforms that I test on (iPhone 3G with OS 3.1.2 and iPhone 4 with OS 4.2.1). I'll describe what I'm doing here and maybe someone can tell me if I'm doing something wrong. In order to rule out the rest of my app, I've whittled this down to a tiny sample app. The app is an iPhone OpenGL Project and it does only this: At startup, allocate 6MB of memory in 30k chunks. This simulates my app

URL forwarding using Chrome webRequest after response is received

随声附和 提交于 2019-11-30 16:22:15
I am attempting to create a Chrome extension that utilizes Chrome's webRequest module to perform a redirect to a URL obtained from an initially accessed URL. For this I would like to utilize only Chrome's webRequest functions (e.g., onBeforeSendHeaders, onHeadersReceived) and not simply perform a call to $.ajax() with the obtained URL. The desired functionality is: User enters a URL in the address bar A request is made and the secondary URL is extracted from the HTTP response The chrome.webRequest.onHeadersReceived handler redirects the user to this secondary URL using the redirectUrl

HttpWebRequests Failing on Subsequent Calls

给你一囗甜甜゛ 提交于 2019-11-30 15:20:08
I know this is a vague question, especially since I am not providing any code, but I am developing a .Net 2.0 application, and we have a WebRequest which posts data to an internally built API. The strange thing happens on our 3rd (and always the 3rd) subsequent request which fails at the GetRequestStream() method of the request. The first and second time its called, all is fine. On the 3rd time, it hangs for a bit and eventually times out. The API is being called by other applications in house, so we know its not a server-side, or networking issue. We've tried on several machines - all of

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

拜拜、爱过 提交于 2019-11-30 14:37:21
问题 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, comments, suggetions why this is? Has anyone else experienced this problem? Dim loHttp As HttpWebRequest = CType(WebRequest.Create(_url), HttpWebRequest) loHttp

c# HttpWebRequest POST'ing failing

青春壹個敷衍的年華 提交于 2019-11-30 13:01:38
So i'm trying to POST something to a webserver. System.Net.HttpWebRequest EventReq = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create("url"); System.String Content = "id=" + Id; EventReq.ContentLength = System.Text.Encoding.UTF8.GetByteCount(Content); EventReq.Method = "POST"; EventReq.ContentType = "application/x-www-form-urlencoded"; System.IO.StreamWriter sw = new System.IO.StreamWriter(EventReq.GetRequestStream(), System.Text.Encoding.UTF8); sw.Write(Content); sw.Flush(); sw.Close(); Looks alright, i'm setting content-length based on the size of the ENCODED data... Anyway it

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

流过昼夜 提交于 2019-11-30 11:08:13
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, comments, suggetions why this is? Has anyone else experienced this problem? Dim loHttp As HttpWebRequest = CType(WebRequest.Create(_url), HttpWebRequest) loHttp.Timeout = 10000 loHttp.Method = "GET" loHttp.KeepAlive = True loHttp.AllowAutoRedirect = True loHttp