webclient

Post fields and a file using the new System.Net.WebClient

流过昼夜 提交于 2019-12-06 15:38:14
i'm trying to invoke a webapi with the new System.Net.WebClient and didnot found any special examples. The goal is simulate a traditional form post with some fields and a file. how can i do it using the System.Net.WebClient or where can i find some examples? thanks in advance I think you need this: http://dzimchuk.net/post/uploading-a-file-over-http-in-net This is a very well written blog. See the last example. There are a lot of examples if you do a fast google search, anyway, here goes some samples: Simple GET WebClient webClient = new WebClient(); webClient.Headers["Accept"] = "application

WebPart on Sharepoint downloads a file locally - I need to send it to the client

放肆的年华 提交于 2019-12-06 13:18:27
please help me to Download file on the machine that use Sharepoint Site not the machine that has sharepoint server. public class WebClientBL { static WebClient client_ = new WebClient() { Credentials = CredentialCache.DefaultNetworkCredentials }; public static void DownloadToClient(string path_in_sp, string path_in_local) { try { client_.DownloadFile(path_in_sp, path_in_local); } catch (Exception ex) { } } } 来源: https://stackoverflow.com/questions/22659661/webpart-on-sharepoint-downloads-a-file-locally-i-need-to-send-it-to-the-client

How to ignore certificate errors in Windows Phone 7?

≡放荡痞女 提交于 2019-12-06 12:02:59
I have searched the internet and I know that in .Net we can use the following codes to ignore certification errors. ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback( delegate { return true; } ); But the certification classes are not supported in windows phone 7 development (know from http://social.msdn.microsoft.com/Forums/en-US/windowsphone7series/thread/4f795a8e-de05-4f01-be7f-0cf2be3a71c2 ). I am now using a WebClient to visit a HTTPS website which requires a certification first. So I am wondering is it possible to ignore the certification

WebClient.DownloadStringAsync throwing Security Exception in Silverlight

谁说胖子不能爱 提交于 2019-12-06 11:07:43
问题 First time using Silverlight ever! Following an online tutorial. I'm creating an app which allows the user to search for stories from the Digg website using a WebClient and displays them in a data grid in a Silverlight control. Here's the code: private void btnSearch_Click(object sender, RoutedEventArgs e) { string topic = txtTopic.Text; string diggUrl = String.Format("http://services.digg.com/stories/topic/{0}?count=20&appkey=http%3A%2F%2Fscottgu.com", topic); WebClient diggService = new

Using a WebClient to save an image with the appropriate extension

浪子不回头ぞ 提交于 2019-12-06 10:52:05
I'm required to retrieve and save an image from a website to my local folder. The image type varies between .png, .jpg and .gif I've tried using string url = @"http://redsox.tcs.auckland.ac.nz/CSS/CSService.svc/"; string saveLoc = @"/project1/home_image"; using (var wc = new WebClient()) { wc.DownloadFile(url, saveLoc); } but this saves the file 'home_image' in the folder without the extension. My question is how do you determine the extension? Is there a simple way to do this? Can one use the Content-Type of the HTTP request? If so, how do you do this? If you want to use a WebClient , then

Dotnet webclient timesout but browser works file for json webservice

泪湿孤枕 提交于 2019-12-06 10:02:59
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 = (HttpWebRequest)WebRequest.Create("https://mtgox.com/code/data/getDepth.php"); using (HttpWebResponse

Does WebClient.OpenFileAsync fire DownloadProgressChanged

社会主义新天地 提交于 2019-12-06 08:59:35
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 += new OpenReadCompletedEventHandler(client_OpenReadCompleted); client.DownloadProgressChanged += new

WebClient upload file error

限于喜欢 提交于 2019-12-06 08:54:29
问题 I am using VSTS 2008 + C# + .Net 3.5 + ASP.Net + IIS 7.0 to develop a console application at client side to upload a file, and at server side I receive this file using an aspx file. From client side, I always notice (from console output) the upload percetage of the file increase from 1% to 50%, then to 100% suddenly. Any ideas what is wrong? Here is my client side code, class Program { private static WebClient client = new WebClient(); private static ManualResetEvent uploadLock = new

HtmlUnit Android problem with WebClient

笑着哭i 提交于 2019-12-06 08:01:29
问题 HtmlUnit is amazing, in Java at least I have had no problems with it. Unfortunately when switching the code over to the Android platform, it is giving me errors when I try to create a web-client. import android.app.Activity; import android.os.Bundle; import com.gargoylesoftware.htmlunit.WebClient; public class AndroidTestActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);

Security rules for subclassing transparent type with safe-critical constructor in Silverlight

坚强是说给别人听的谎言 提交于 2019-12-06 07:49:27
问题 In the Silverlight (v4.0) security model, Shawn Farkas says of deriving from types: [...] we see that application types may only derive from other application types or transparent platform types. (*) The * part of this is: (*) This true in 99.9% case. There is another rule about the visibility of the default constructor of a class (which we'll get into next week when we dig deeper into the security model), which also requires that the base class' default constructor (if it has one), must be