webclient

WebClient.DownloadProgressChanged: Console.WriteLine() is blocking UI thread

北慕城南 提交于 2019-12-08 04:48:23
问题 I have the following simple code: private void btn_download_Click(object sender, EventArgs e){ WebClient client = new WebClient(); client.DownloadProgressChanged += client_DownloadProgressChanged; client.DownloadFileAsync(new Uri("http://.../file.zip"), "file.zip"); } void client_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e){ //Prints: "Downloaded 3mb of 61.46mb (4%)" Console.WriteLine("Downloaded " + ((e.BytesReceived / 1024f) / 1024f).ToString("#0.##") + "mb" +

apache HTMLUNIT… PROBLEM in handling javascript

ε祈祈猫儿з 提交于 2019-12-08 04:05:26
I want to login to a website ( http://www.orkut.com ) through com.gargoylesoftware.htmlunit.WebClient But when I click on the "Submit" button, it doesn't take me to the expected page that should come after login. Instead it returns the same login page again. In clear sense, there is some problem in login. When I try the same code with sites that doen't have javascript, it works fine so I think I am not able to handle scripts. I am trying using the follwoing code: public static void main(String[] args) { final WebClient webClient = new WebClient(); try { HtmlPage loginPage = webClient.getPage

C# HttpWebRequest GET partially encoded url

筅森魡賤 提交于 2019-12-08 04:02:26
问题 When I send a get using HttpWebRequest is seems to turn it into a uri, run it through an encoder and send the encoded string. When I look at my address in the request after it is created I have the OriginalString which is correct and an AbsoluteUri which is encoded and incorrect. My code and example urls are below. HttpWebRequest webRequest = System.Net.WebRequest.Create(url) as HttpWebRequest; String responseData = WebResponseGet(webRequest); OriginalString:"https://api.linkedin.com/v1

Dotnet webclient timesout but browser works file for json webservice

邮差的信 提交于 2019-12-08 02:10:00
问题 I am trying to get the result of the following json webservice https://mtgox.com/code/data/getDepth.php into a string using the following code. using (WebClient client = new WebClient()) { string data = client.DownloadString("https://mtgox.com/code/data/getDepth.php"); } but it always returns a timeout exception and no data. I plan to use fastjson to turn the response into objects and expected that to be that hard part not the returning of the content of the page. HttpWebRequest request =

Does WebClient.OpenFileAsync fire DownloadProgressChanged

谁都会走 提交于 2019-12-07 23:57:39
问题 According to http://msdn.microsoft.com/en-us/library/system.net.webclient.downloadprogresschanged.aspx, OpenFileAsync should have DownloadProgressChanged firing whenever it makes progress. I can't get it to fire at all. Fires fine with DownloadDataAsync and DownloadFileAsync instead though. Here's a simple example: using System; using System.Net; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { WebClient client = new WebClient(); client.OpenReadCompleted +=

Get current Uri when redirected in WebClient wp7

三世轮回 提交于 2019-12-07 17:45:29
问题 I hope that I won't start a topic that's done already but I didn't find any proper answer here nor anywere else. So here we go: I use a WebClient to download HTML Code from a webpage, then I send a new request with that WebClient and the WebPage redirects me. Now I want to now where the Site has put me. The WebClient Class itself doesn't have any suitable properties, I already tried to rewrite the class so that I could get the Response URI but somehow it doesn't work for wp7. So any ideas how

WebClient forbids opening wikipedia page?

心不动则不痛 提交于 2019-12-07 17:03:47
问题 Here's the code I'm trying to run: var wc = new WebClient(); var stream = wc.OpenRead( "http://en.wikipedia.org/wiki/List_of_communities_in_New_Brunswick"); But I keep getting a 403 forbidden error. Don't understand why. It worked fine for other pages. I can open the page fine in my browser. How can I fix this? 回答1: I wouldn't normally use OpenRead() , try DownloadData() or DownloadString() instead. Also it might be that wikipedia is deliberately blocking your request because you have not

how to wait for webclient OpenReadAsync to complete

蹲街弑〆低调 提交于 2019-12-07 16:27:31
问题 I am using WebClient to download some stuff from internet in Windows Phone 8.1 app. Below is the sample code i am using in my app - where i am calling below method, but my webclient is not waiting to complete the read operation and returning immediately after OpenReadAsync call. how can i make sure that my method return operation must wait till OpenReadCompleted event is completed? I have seen multiple similar questions, but couldn't find a solution. MyCustomObject externalObj; // my custom

WebClient DownloadFileAsync() blocks thread

守給你的承諾、 提交于 2019-12-07 14:47:31
问题 I'm trying to download a large file (500 mb) from my webserver using WPF and MVVM. Thus the following properties are all bound to some kind of controls (progressbar). The problem is, that the application still hangs, even while using DownloadFileAsync. The file is being downloaded as I can tell from my logs (and the file growing, of course). This is my code: #region Methods private void StartDownload(string url, string localPath) { Logger.Debug("Starting to initialize file download"); if (!

Login using WebClient or HttpWebRequest

☆樱花仙子☆ 提交于 2019-12-07 13:57:33
问题 Iam having serious problem with login. I cant use WebBrowser class to login to site because WebBrowser is only single thread class. I cannot login with WebClient because I dont have a cookies. Tried to login with HttpWebRequest and Iam guessing I logged succesfully because i got header with: login.success or something like that, but when I retreived source page it returned me login page showing me that Iam not logged. Iam trying to login to this page: https://lite.betfair.com/Login.do?s