diff --git a/src/Umbraco.Web/Editors/CanvasDesignerController.cs b/src/Umbraco.Web/Editors/CanvasDesignerController.cs index 722167d18a..8284bf0b12 100644 --- a/src/Umbraco.Web/Editors/CanvasDesignerController.cs +++ b/src/Umbraco.Web/Editors/CanvasDesignerController.cs @@ -20,9 +20,10 @@ using Umbraco.Core.Services; namespace Umbraco.Web.Editors { - + public class CanvasDesignerController : UmbracoApiController { + private static WebClient _webClient; [HttpGet] public HttpResponseMessage GetGoogleFont() @@ -35,10 +36,10 @@ namespace Umbraco.Web.Editors var googleWebFontAPIURL = string.Format("https://www.googleapis.com/webfonts/v1/webfonts?key={0}", APIKey); var response = "{}"; - using (var client = new System.Net.WebClient()) - { - response = client.DownloadString(new Uri(googleWebFontAPIURL)); - } + if (_webClient == null) + _webClient = new WebClient(); + + response = _webClient.DownloadString(new Uri(googleWebFontAPIURL)); var resp = Request.CreateResponse(); resp.Content = new StringContent(response); @@ -59,7 +60,7 @@ namespace Umbraco.Web.Editors // Prepare string parameter result string[] paramLines = paramBlock.Trim().Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries); - IList parameters = new List(); + IList parameters = new List(); foreach (var line in paramLines) { if (!line.Contains("@import")) @@ -121,4 +122,4 @@ namespace Umbraco.Web.Editors } -} \ No newline at end of file +} diff --git a/src/Umbraco.Web/Install/InstallSteps/NewInstallStep.cs b/src/Umbraco.Web/Install/InstallSteps/NewInstallStep.cs index dfcb441cce..0eaf3cc663 100644 --- a/src/Umbraco.Web/Install/InstallSteps/NewInstallStep.cs +++ b/src/Umbraco.Web/Install/InstallSteps/NewInstallStep.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Collections.Specialized; using System.Configuration; +using System.Net; using System.Web; using System.Web.Security; using Umbraco.Core; @@ -80,7 +81,7 @@ namespace Umbraco.Web.Install.InstallSteps { try { - var client = new System.Net.WebClient(); + var client = new WebClient(); var values = new NameValueCollection { { "name", admin.Name }, { "email", admin.Email} }; client.UploadValues("https://shop.umbraco.com/base/Ecom/SubmitEmail/installer.aspx", values); } diff --git a/src/Umbraco.Web/Media/EmbedProviders/AbstractOEmbedProvider.cs b/src/Umbraco.Web/Media/EmbedProviders/AbstractOEmbedProvider.cs index 2f8ec85075..737b04fc83 100644 --- a/src/Umbraco.Web/Media/EmbedProviders/AbstractOEmbedProvider.cs +++ b/src/Umbraco.Web/Media/EmbedProviders/AbstractOEmbedProvider.cs @@ -12,18 +12,20 @@ namespace Umbraco.Web.Media.EmbedProviders { //TODO: Make all Http calls async - public abstract class AbstractOEmbedProvider: IEmbedProvider + public abstract class AbstractOEmbedProvider : IEmbedProvider { + private static WebClient _webClient; + public virtual bool SupportsDimensions { get { return true; } } [ProviderSetting] - public string APIEndpoint{ get;set; } + public string APIEndpoint { get; set; } [ProviderSetting] - public Dictionary RequestParams{ get;set; } + public Dictionary RequestParams { get; set; } public abstract string GetMarkup(string url, int maxWidth, int maxHeight); @@ -51,10 +53,9 @@ namespace Umbraco.Web.Media.EmbedProviders public virtual string DownloadResponse(string url) { - using (var webClient = new WebClient()) - { - return webClient.DownloadString(url); - } + if (_webClient == null) + _webClient = new WebClient(); + return _webClient.DownloadString(url); } public virtual T GetJsonResponse(string url) where T : class @@ -79,4 +80,4 @@ namespace Umbraco.Web.Media.EmbedProviders } } -} \ No newline at end of file +} diff --git a/src/Umbraco.Web/umbraco.presentation/keepAliveService.cs b/src/Umbraco.Web/umbraco.presentation/keepAliveService.cs index abc3425f3f..192c35a233 100644 --- a/src/Umbraco.Web/umbraco.presentation/keepAliveService.cs +++ b/src/Umbraco.Web/umbraco.presentation/keepAliveService.cs @@ -10,8 +10,9 @@ namespace umbraco.presentation [Obsolete("This is no longer used and will be removed in future versions")] public class keepAliveService { + private static WebClient _webClient; //NOTE: sender will be the umbraco ApplicationContext - public static void PingUmbraco(object sender) + public static void PingUmbraco(object sender) { if (sender == null || !(sender is ApplicationContext)) return; @@ -21,10 +22,9 @@ namespace umbraco.presentation var url = appContext.UmbracoApplicationUrl + "/ping.aspx"; try { - using (var wc = new WebClient()) - { - wc.DownloadString(url); - } + if (_webClient == null) + _webClient = new WebClient(); + _webClient.DownloadString(url); } catch(Exception ee) { @@ -32,4 +32,4 @@ namespace umbraco.presentation } } } -} \ No newline at end of file +} diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/dashboard/FeedProxy.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/dashboard/FeedProxy.aspx.cs index b304cda0b6..488e4f06c2 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/dashboard/FeedProxy.aspx.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/dashboard/FeedProxy.aspx.cs @@ -1,4 +1,5 @@ -using Umbraco.Core.Logging; +using System.Net.Http; +using Umbraco.Core.Logging; using Umbraco.Web; namespace dashboardUtilities @@ -14,6 +15,8 @@ namespace dashboardUtilities public partial class FeedProxy : UmbracoEnsuredPage { + private static WebClient _webClient; + protected void Page_Load(object sender, EventArgs e) { try @@ -31,9 +34,10 @@ namespace dashboardUtilities && feedProxyXml.SelectSingleNode(string.Concat("//allow[@host = '", requestUri.Host, "']")) != null && requestUri.Port == 80) { - using (var client = new WebClient()) - { - var response = client.DownloadString(requestUri); + if (_webClient == null) + _webClient = new WebClient(); + + var response = _webClient.DownloadString(requestUri); if (string.IsNullOrEmpty(response) == false) { @@ -41,7 +45,7 @@ namespace dashboardUtilities Response.ContentType = Request.CleanForXss("type") ?? MediaTypeNames.Text.Xml; Response.Write(response); } - } + } else { @@ -57,4 +61,4 @@ namespace dashboardUtilities } } } -} \ No newline at end of file +} diff --git a/src/umbraco.cms/businesslogic/Packager/Installer.cs b/src/umbraco.cms/businesslogic/Packager/Installer.cs index a502ef5a32..eb46e82e8b 100644 --- a/src/umbraco.cms/businesslogic/Packager/Installer.cs +++ b/src/umbraco.cms/businesslogic/Packager/Installer.cs @@ -14,6 +14,7 @@ using umbraco.cms.businesslogic.web; using umbraco.BusinessLogic; using System.Diagnostics; using System.IO.Compression; +using System.Net; using umbraco.cms.businesslogic.template; using umbraco.interfaces; using Umbraco.Core.Events; @@ -685,7 +686,7 @@ namespace umbraco.cms.businesslogic.packager if (Directory.Exists(IOHelper.MapPath(SystemDirectories.Packages)) == false) Directory.CreateDirectory(IOHelper.MapPath(SystemDirectories.Packages)); - var wc = new System.Net.WebClient(); + var wc = new WebClient(); wc.DownloadFile( "http://" + PackageServer + "/fetch?package=" + Package.ToString(),