webclient

Web.config jsonSerialization maxJsonLength ignored

穿精又带淫゛_ 提交于 2019-12-04 07:19:46
I have an MVC3 application running under .NET 4.0 and when I use JavascriptSerializer.Deserialize I'm getting an error. Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property. Reading Can I set an unlimited length for maxJsonLength in web.config I put the jsonSerialization maxJsonLength key in my web.config but it gets ignored. Though I can set the JavaScriptSerializer.MaxJsonLength property in code and it works fine. I would like to have the value in the Web.config rather than code. Here

Error Reading RSS Feed using LINQ to XML

三世轮回 提交于 2019-12-04 07:04:43
问题 In referencing this article I am receiving a NullReferenceException stating Object reference is not set to an instance of an object. I'm not sure how to fix this solution as I've followed the steps in my reference article. Models public class RssModel { public string Title { get; set; } public string Link { get; set; } public string Description { get; set; } public string Image { get; set; } } public class ReadRssModel { public static List<RssModel> GetRss() { var client = new WebClient();

WebClient.DownloadDataAsync is freezing my UI

纵然是瞬间 提交于 2019-12-04 06:24:38
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 to do this without freezing the UI? Thanks for your time. Best regards. FULL CODE: Program.cs using

WebClient Download - “Access to the path 'c:\\windows\\system32\\inetsrv\\MyPrintManager.exe' is denied”

蓝咒 提交于 2019-12-04 06:24:19
问题 I am attempting to download a file from another IIS site on my local machine. I have my main website that is trying to download from another public site that contains a few files that the user will be able to download. [HttpGet] public ActionResult DownloadMyPrintManagerInstaller() { bool success; try { using (var client = new WebClient()) { client.DownloadFile(new Uri("http://localhost:182//MyPrintInstaller.exe"), "MyPrintManager.exe"); } success = true; } catch (Exception) { success = false

Compiling new type in PowerShell v2 - Cookie Aware WebClient

拟墨画扇 提交于 2019-12-04 05:09:11
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.GetWebRequest(address); if (request is System.Net.HttpWebRequest) { (request as System.Net.HttpWebRequest)

The operation has timed out with WebClient.DownloadFile and correct url's

余生长醉 提交于 2019-12-04 04:06:49
I am batch uploading products to a database. I am download the image urls to the site to be used for the products. The code I written works fine for the first 25 iterations (always that number for some reason), but then throws me a System.Net.WebException "The operation has timed out". if (!File.Exists(localFilename)) { using (WebClient Client = new WebClient()) { Client.DownloadFile(remoteFilename, localFilename); } } I checked the remote url it was requesting and it is a valid image url that returns an image. Also, when I step through it with the debugger, I don't get the timeout error. HELP

Getting error “Provider com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl not found” in unit test but not in main program

。_饼干妹妹 提交于 2019-12-04 03:47:15
I am building an application in C# which uses com.gargoylesoftware.htmlunit.WebClient to access and retrieve information from webpages. My application runs fine from the main project but when I try to build unit tests to test the project classes I get the following error: FactoryConfigurationError Message "Provider com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl not found" Source "IKVM.OpenJDK.XML.API" string StackTrace " at javax.xml.parsers.DocumentBuilderFactory.newInstance() at com.gargoylesoftware.htmlunit.javascript.configuration.JavaScriptConfiguration

The remote name could not be resolved - webclient

做~自己de王妃 提交于 2019-12-04 03:29:12
I am facing this error : The remote name could not be resolved: 'russgates85-001-site1.smarterasp.net' When I request html contents to read using web client it gives me error. Below is my code. string strHTML = string.Empty; WebClient myClient = new WebClient(); UTF8Encoding utf8 = new UTF8Encoding(); byte[] requestHTML; string pdfFileName = "outputpdf_" + DateTime.Now.Ticks + ".pdf"; string webUrl = Request.Url.Scheme + "://" + Request.Url.Host + (Request.Url.Port != 80 ? ":" + Request.Url.Port : ""); requestHTML = myClient.DownloadData("http://russgates85-001-site1.smarterasp.net/adminsec

How to deal with exceptions when using WebClient.DownloadFileAsync

无人久伴 提交于 2019-12-04 03:28:23
问题 I am downloading some files from the internet using a WebClient in the following way: try { ManualResetEvent mr = new ManualResetEvent(false); mr.Reset(); using (WebClient wc = new WebClient()) { wc.DownloadFileCompleted += ((sender, args) => { if (args.Error == null) { File.Move(filePath, Path.ChangeExtension(filePath, ".jpg")); mr.Set(); } else { //how to pass args.Error? } }); wc.DownloadFileAsync(new Uri(string.Format("{0}/{1}", Settings1.Default.WebPhotosLocation, Path.GetFileName(f

On which thread(s) does WebClient raise its events?

血红的双手。 提交于 2019-12-04 03:09:04
问题 I can not find any documentation that specifies on which thread WebClient raises its events. I ran some tests and determined the following: If called from a UI thread (say from an event handler) the event handler will be executed on that thread. As a test, I added an infinite loop after the call to OpenReadAsync. The event handler was never called. If there is no UI thread, like in a console application, the event handler will be executed on a thread pool thread. In this case, if I wanted to