diff --git a/build/build.ps1 b/build/build.ps1 index 9d83b81d7..704e14555 100644 --- a/build/build.ps1 +++ b/build/build.ps1 @@ -49,7 +49,7 @@ $imageprocessorWebConfig = @{ $imageProcessorWebPluginsAzureBlobCache = @{ name = "ImageProcessor.Web.Plugins.AzureBlobCache" - version = "1.7.0" + version = "1.7.1" folder = Join-Path $buildPath "src\ImageProcessor.Web.Plugins.AzureBlobCache" output = Join-Path $binPath "ImageProcessor.Web.Plugins.AzureBlobCache\lib\net452" csproj = "ImageProcessor.Web.Plugins.AzureBlobCache.csproj" diff --git a/src/ImageProcessor.Web.Plugins.AzureBlobCache/AzureBlobCache.cs b/src/ImageProcessor.Web.Plugins.AzureBlobCache/AzureBlobCache.cs index d3c3b6587..a880aaa40 100644 --- a/src/ImageProcessor.Web.Plugins.AzureBlobCache/AzureBlobCache.cs +++ b/src/ImageProcessor.Web.Plugins.AzureBlobCache/AzureBlobCache.cs @@ -16,6 +16,7 @@ namespace ImageProcessor.Web.Plugins.AzureBlobCache using System.IO; using System.Linq; using System.Net; + using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; using System.Web; @@ -357,18 +358,25 @@ public override void RewritePath(HttpContext context) catch (StorageException ex) { // A 304 is not a true error, we still need to feed back. - var webException = ex.InnerException as WebException; - if (!(webException is null)) + if (ex.RequestInformation?.HttpStatusCode == (int)HttpStatusCode.NotModified) { - if (webException.Response != null && (((HttpWebResponse)webException.Response).StatusCode == HttpStatusCode.NotModified)) - { - is304 = true; - } - else - { - ImageProcessorBootstrapper.Instance.Logger.Log("Unable to stream cached path: " + this.cachedRewritePath); - return; - } + is304 = true; + } + else if (ex.InnerException is WebException webException + && webException.Response is HttpWebResponse httpWebResponse + && httpWebResponse.StatusCode == HttpStatusCode.NotModified) + { + is304 = true; + } + else + { + var sb = new StringBuilder(); + sb.AppendFormat("Unable to stream cached path: {0}", this.cachedRewritePath); + sb.AppendLine(); + sb.AppendFormat("Exception: {0}", ex.ToString()); + + ImageProcessorBootstrapper.Instance.Logger.Log(sb.ToString()); + return; } }