webclient

Silverlight 4, subclassing WebClient

天大地大妈咪最大 提交于 2019-12-06 05:51:26
问题 Following an advice, I saw at several web pages (for example Using CookieContainer with WebClient class), I subclassed WebClient class to use a cookie with it: public class MyWebClient : System.Net.WebClient { } Now, when I initialize MyWebClient: MyWebClient wc = new MyWebClient(); it throws TypeLoadException. My OS is Windows 7 (japanese), so error message is not in english; I see it is related to security rules. What might be the problem? 回答1: WebClient's constructor is marked with the

How to download all files from web URL?

江枫思渺然 提交于 2019-12-06 04:10:32
I want to get all files from URL. files may be different types of extensions. How I get all files with webclient object from Website URL. when I open website Url then files listed as below format ... Frame.js MyFile.png Class1.cs "Files and folder list from web URL" You need to write yourself a very simple web crawler. Google for 'C# web crawler' and you will find a number of blogs with simple implementations such as this one: How To: Write a Crawler in C# As I can see your platform is Windows. If you are just looking for a tool to download all the files please look at wget in http://unxutils

How to download a whole folder of files/subfolders from the web in PowerShell

非 Y 不嫁゛ 提交于 2019-12-06 02:32:18
问题 I can download a single file from the web using: $wc = New-Object System.Net.WebClient $wc.DownloadFile("http://blah/root/somefile.ext", "C:\Downloads\www\blah\root\somefile.ext") But how do I download all the files, including subfolders? Something like the following would be nice... $wc.DownloadFile("http://blah/root/", "C:\Downloads\www\blah\root\") The root folder itself appears as a directory listing in IE, you know, like: [To Parent Directory] 01 July 2012 09:00 1234 somefile.ext 01 July

WebClient.DownloadDataAsync is freezing my UI

廉价感情. 提交于 2019-12-06 02:17:27
问题 I have in my Form constructor, after the InitializeComponent the following code: using (WebClient client = new WebClient()) { client.DownloadDataCompleted += new DownloadDataCompletedEventHandler(client_DownloadDataCompleted); client.DownloadDataAsync("http://example.com/version.txt"); } When I start my form, the UI doesn't appears till client_DownloadDataCompleted is raised. The client_DownloadDataCompleted method is empty, so there's no problem there. What I'm doing wrong? How is supposed

Readable debug logging for http requests with spring webclient

对着背影说爱祢 提交于 2019-12-06 01:31:02
问题 I'm using Spring reactive WebClient for sending requests to a http server. Inorder to view the underlying request & response that's being sent, I enabled debug logging for reactor.ipc.netty package. The headers for the outgoing requests can be viewed normally. Tho I'm sending & receiving plain text over http, the log contains the request & responses in the below format (is it hex?) I'm not sure how to view the logged data in a easy to understand way. Better yet log the request & response in a

Compiling new type in PowerShell v2 - Cookie Aware WebClient

夙愿已清 提交于 2019-12-06 00:22:29
问题 I am trying to compile a "cookie aware" version of the WebClient class - but I can't seem to get over some of the hurdles of using the Add-Type cmdlet added in PowerShell v2. Here is the code I am trying to compile: PS C:\> $def = @" public class CookieAwareWebClient : System.Net.WebClient { private System.Net.CookieContainer m_container = new System.Net.CookieContainer(); protected override System.Net.WebRequest GetWebRequest(System.Uri address) { System.Net.WebRequest request = base

Slow WebClient.DownloadString?

折月煮酒 提交于 2019-12-05 21:42:52
I'm working on a web application that runs with ASP.Net 3.5 Somewhere in the application, I'm making calls to an external system. This call consists on downloading a string from a specific url : string targetUrl = BuildMyUrl(); WebClient wc = new WebClient(); string data = wc.DownloadString(targetUrl); This code works quite well with a acceptable response time (under 500ms). However, in specific cases this response time is over 15 seconds. I can reproduce the behavior, and I can clearly see the long time is on the DownloadString call. I don't understand why this occurs in my scenario . You

Infinite loop while downloading multiple files with WebClient

我与影子孤独终老i 提交于 2019-12-05 20:44:28
The conception: I'm making a C# app which downloads files from a given URL. Textbox, url added, file downloads, every event occurs in the correct way. I'm trying to recreate this program to download multiple files, one by one. I have a textbox with one url/line, parsing happens correctly, I have all the links in a string array which was placed in the textbox. Then it starts downloading async, and I wanted to make it download only one by one, so I made a while loop in a foreach loop, as I don't want to go to the next url until the current one has finished downloading. The problem is: I get in

WebClient forbids opening wikipedia page?

偶尔善良 提交于 2019-12-05 19:48:56
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? JK. 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 provided a user agent string: WebClient client = new WebClient(); client.Headers.Add("user-agent", "Mozilla

How to limit the number of active Spring WebClient calls

白昼怎懂夜的黑 提交于 2019-12-05 19:15:58
I have a requirement where I read a bunch of rows (thousands) from a SQL DB using Spring Batch and call a REST Service to enrich content before writing them on a Kafka topic. When using the Spring Reactive webClient, how do I limit the number of active non-blocking service calls? Should I somehow introduce a Flux in the loop after I read data using Spring Batch? (I understand the usage of delayElements and that it serves a different purpose, as when a single Get Service Call brings in lot of data and you want the server to slow down -- here though, my use case is a bit different in that I have