webclient

nodejs, expressjs serving PHP files

假装没事ソ 提交于 2019-12-30 06:42:14
问题 Ok I've been playing around with nodejs, expressjs and socket.io to create some applications. But now im coming to the stage where i want to take things a bit further. I have noticed a few node apps using PHP for twitter auth on their client side. When I attempt to rename my client.html file to client.php and restart the server it throws up a blank page with this Cannot GET / How do would serve php files or would i do twitter auto using js? This is my NodeJS server.js var http = require('http

WebClient UploadFileAsync strange behaviour in progress reporting

与世无争的帅哥 提交于 2019-12-30 06:09:00
问题 i need some help with strange WebClient.UploadFileAsync()'s behaviour. I'm uploading a file to a remote HTTP Server (nginx) usind POST Method. The POST is processed trough a PHP script (which Address refers to). I have this simple code public void uploadFile(string filePath) { webClient = new WebClient(); webClient.Credentials = new NetworkCredential(Constant.HTTPUsername,Constant.HTTPPassword); webClient.Headers.Add("Test", TestKey); webClient.UploadProgressChanged += webClient

WebClient UploadFileAsync strange behaviour in progress reporting

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-30 06:05:43
问题 i need some help with strange WebClient.UploadFileAsync()'s behaviour. I'm uploading a file to a remote HTTP Server (nginx) usind POST Method. The POST is processed trough a PHP script (which Address refers to). I have this simple code public void uploadFile(string filePath) { webClient = new WebClient(); webClient.Credentials = new NetworkCredential(Constant.HTTPUsername,Constant.HTTPPassword); webClient.Headers.Add("Test", TestKey); webClient.UploadProgressChanged += webClient

WebClient DownloadFileAsync - How can I display download speed to the user?

馋奶兔 提交于 2019-12-30 05:06:06
问题 That's pretty much the whole question in the title. I have a WPF C# Windows application, I download files for the user and now want to display the speed. 回答1: mWebClient.DownloadProgressChanged += (sender, e) => progressChanged(e.BytesReceived); //... DateTime lastUpdate; long lastBytes = 0; private void progressChanged(long bytes) { if (lastBytes == 0) { lastUpdate = DateTime.Now; lastBytes = bytes; return; } var now = DateTime.Now; var timeSpan = now - lastUpdate; var bytesChange = bytes -

How to set WebClient Content-Type Header?

ぐ巨炮叔叔 提交于 2019-12-30 03:44:04
问题 To conect to a third party service I need to make a Https Post. One of the requisites set is to sent a custom content type. I'm using WebClient, but I can't find how to set it. I've tried making a new class and overriding the CreateRequest Method, but that make request crash. Is there any way to do that without having to rewrite CopyHeadersTo method? EDIT CopyHeaderTo is a method I've seen using .NET Reflector. It's invoked from GetWebRequest and sets all Request Headers, including Content

.NET: Do I need to keep a reference to WebClient while downloading asynchronously?

一笑奈何 提交于 2019-12-29 04:19:08
问题 I use the following method in a piece of production code: private void DownloadData(Uri uri) { WebClient webClient = new WebClient(); DownloadDataCompletedEventHandler eh = null; eh = delegate(object sender, DownloadDataCompletedEventArgs e) { webClient.DownloadDataCompleted -= eh; ((IDisposable) webClient).Dispose(); OnDataDownloaded(); }; webClient.DownloadDataCompleted += eh; webClient.DownloadDataAsync(uri); } I am now worried that a hard to reproduce bug might be caused by the WebClient

Load URL from txt File and load the URL in Browser Synchronous WebClient httpRequest

ε祈祈猫儿з 提交于 2019-12-29 02:01:12
问题 I started Windows Phone programming with this example from Microsoft: http://code.msdn.microsoft.com/wpapps/Hybrid-Web-App-75b7ef74/view/SourceCode The app only displays the browser and load a URL. Now I want to load an other URL directly from a .txt file. For example: http://www.test.de/appurl.txt and then I want to load the URL in the Windows Phone App. --> For example: http://anotherserver.de/index.html?mobileApp My problem is, that the URL have to load synchronous and not asynchronous. I

WebClient + HTTPS Issues

十年热恋 提交于 2019-12-28 04:59:32
问题 I am currently integrating with a system created by a 3rd party. This system requires me to send a request using XML/HTTPS. The 3rd party send me the certificate and I installed it I use the following code: using (WebClient client = new WebClient()) { client.Headers.Add(HttpRequestHeader.ContentType, "text/xml"); System.Text.ASCIIEncoding encoding=new System.Text.ASCIIEncoding(); var response = client.UploadData(address, "POST", encoding.GetBytes(msg)); } This code returns the following

Read file from FTP to memory in C#

孤人 提交于 2019-12-28 04:08:08
问题 I want to read a file from a FTP server without downloading it to a local file. I wrote a function but it does not work: private string GetServerVersion() { WebClient request = new WebClient(); string url = FtpPath + FileName; string version = ""; request.Credentials = new NetworkCredential(ftp_user, ftp_pas); try { byte[] newFileData = request.DownloadData(new Uri(FtpPath)+FileName); string fileString = System.Text.Encoding.UTF8.GetString(newFileData); } catch (WebException e) { } return

WebClient runs javascript

≡放荡痞女 提交于 2019-12-28 02:53:22
问题 I have one. aspx page that has some JavaScript functions that control paging. I can run this javascript function via webbrowser with the following method within the WebBrowser1_DocumentCompleted WebBrowser1.Document.Window.DomWindow.execscript ("somefunction();", "JavaScript") The webbrowser is very slow and I prefer to use System.Net.WebClient.DownloadString . Has some way to run this script with the System.Net.WebClient methods that are faster, or some other way? 回答1: Well, no. WebClient is