diff --git a/src/ImageProcessor.Web/NET4/ImageProcessor.Web_NET4.csproj b/src/ImageProcessor.Web/NET4/ImageProcessor.Web_NET4.csproj
index 6c01a8bcc..f8c863616 100644
--- a/src/ImageProcessor.Web/NET4/ImageProcessor.Web_NET4.csproj
+++ b/src/ImageProcessor.Web/NET4/ImageProcessor.Web_NET4.csproj
@@ -51,6 +51,10 @@
..\..\packages\Microsoft.Bcl.Async.1.0.165\lib\net40\Microsoft.Threading.Tasks.Extensions.Desktop.dll
+
+ True
+ ..\..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll
+
@@ -86,6 +90,9 @@
ImageHelpers.cs
+
+ StartUp.cs
+
diff --git a/src/ImageProcessor.Web/NET4/packages.config b/src/ImageProcessor.Web/NET4/packages.config
index 86eb14bb5..18cb40932 100644
--- a/src/ImageProcessor.Web/NET4/packages.config
+++ b/src/ImageProcessor.Web/NET4/packages.config
@@ -3,4 +3,5 @@
+
\ No newline at end of file
diff --git a/src/ImageProcessor.Web/NET45/Config/ImageProcessorConfig.cs b/src/ImageProcessor.Web/NET45/Config/ImageProcessorConfig.cs
index 76c2a91f3..d5f457798 100644
--- a/src/ImageProcessor.Web/NET45/Config/ImageProcessorConfig.cs
+++ b/src/ImageProcessor.Web/NET45/Config/ImageProcessorConfig.cs
@@ -13,12 +13,9 @@ namespace ImageProcessor.Web.Config
#region Using
using System;
using System.Collections.Generic;
- using System.IO;
using System.Linq;
using System.Reflection;
- using System.Text;
using System.Web.Compilation;
-
using ImageProcessor.Processors;
#endregion
@@ -300,7 +297,7 @@ namespace ImageProcessor.Web.Config
.SelectMany(s => s.GetTypes())
.Where(t => t != null && type.IsAssignableFrom(t) && t.IsClass && !t.IsAbstract)
.ToList();
-
+
// Create them and add.
this.GraphicsProcessors = availableTypes.Select(x => (Activator.CreateInstance(x) as IGraphicsProcessor)).ToList();
@@ -310,7 +307,7 @@ namespace ImageProcessor.Web.Config
processor.Settings = this.GetPluginSettings(processor.GetType().Name);
}
}
- catch (ReflectionTypeLoadException ex)
+ catch (ReflectionTypeLoadException)
{
this.LoadGraphicsProcessorsFromConfiguration();
}
diff --git a/src/ImageProcessor.Web/NET45/Helpers/StartUp.cs b/src/ImageProcessor.Web/NET45/Helpers/StartUp.cs
new file mode 100644
index 000000000..81310e620
--- /dev/null
+++ b/src/ImageProcessor.Web/NET45/Helpers/StartUp.cs
@@ -0,0 +1,31 @@
+// --------------------------------------------------------------------------------------------------------------------
+//
+// Copyright (c) James South.
+// Licensed under the Apache License, Version 2.0.
+//
+//
+// Provides methods to handle startup events.
+//
+// --------------------------------------------------------------------------------------------------------------------
+
+[assembly: System.Web.PreApplicationStartMethod(typeof(ImageProcessor.Web.Helpers.StartUp), "PreApplicationStart")]
+
+namespace ImageProcessor.Web.Helpers
+{
+ using ImageProcessor.Web.HttpModules;
+ using Microsoft.Web.Infrastructure.DynamicModuleHelper;
+
+ ///
+ /// Provides methods to handle startup events.
+ ///
+ public static class StartUp
+ {
+ ///
+ /// The pre application start.
+ ///
+ public static void PreApplicationStart()
+ {
+ DynamicModuleUtility.RegisterModule(typeof(ImageProcessingModule));
+ }
+ }
+}
diff --git a/src/ImageProcessor.Web/NET45/HttpModules/ImageProcessingModule.cs b/src/ImageProcessor.Web/NET45/HttpModules/ImageProcessingModule.cs
index ae4700ba2..7d7024584 100644
--- a/src/ImageProcessor.Web/NET45/HttpModules/ImageProcessingModule.cs
+++ b/src/ImageProcessor.Web/NET45/HttpModules/ImageProcessingModule.cs
@@ -31,6 +31,9 @@ namespace ImageProcessor.Web.HttpModules
using ImageProcessor.Web.Caching;
using ImageProcessor.Web.Config;
using ImageProcessor.Web.Helpers;
+
+ using Microsoft.Web.Infrastructure.DynamicModuleHelper;
+
#endregion
///
@@ -49,11 +52,6 @@ namespace ImageProcessor.Web.HttpModules
///
private static readonly Regex PresetRegex = new Regex(@"preset=[^&]*", RegexOptions.Compiled);
- ///
- /// The value to prefix any remote image requests with to ensure they get captured.
- ///
- private static readonly string RemotePrefix = ImageProcessorConfig.Instance.RemotePrefix;
-
///
/// The assembly version.
///
@@ -64,6 +62,11 @@ namespace ImageProcessor.Web.HttpModules
///
private static readonly Dictionary SemaphoreSlims = new Dictionary();
+ ///
+ /// The value to prefix any remote image requests with to ensure they get captured.
+ ///
+ private static string remotePrefix;
+
///
/// A value indicating whether this instance of the given entity has been disposed.
///
@@ -109,17 +112,17 @@ namespace ImageProcessor.Web.HttpModules
///
public void Init(HttpApplication context)
{
-#if NET45
+ if (remotePrefix == null)
+ {
+ remotePrefix = ImageProcessorConfig.Instance.RemotePrefix;
+ }
+#if NET45
EventHandlerTaskAsyncHelper wrapper = new EventHandlerTaskAsyncHelper(this.PostAuthorizeRequest);
context.AddOnPostAuthorizeRequestAsync(wrapper.BeginEventHandler, wrapper.EndEventHandler);
-
#else
-
context.PostAuthorizeRequest += this.PostAuthorizeRequest;
-
#endif
-
context.PreSendRequestHeaders += this.ContextPreSendRequestHeaders;
}
@@ -264,7 +267,7 @@ namespace ImageProcessor.Web.HttpModules
HttpRequest request = context.Request;
// Fixes issue 10.
- bool isRemote = request.Path.EndsWith(RemotePrefix, StringComparison.OrdinalIgnoreCase);
+ bool isRemote = request.Path.EndsWith(remotePrefix, StringComparison.OrdinalIgnoreCase);
string requestPath = string.Empty;
string queryString = string.Empty;
diff --git a/src/ImageProcessor.Web/NET45/ImageProcessor.Web_NET45.csproj b/src/ImageProcessor.Web/NET45/ImageProcessor.Web_NET45.csproj
index cdb14683e..e40a4f641 100644
--- a/src/ImageProcessor.Web/NET45/ImageProcessor.Web_NET45.csproj
+++ b/src/ImageProcessor.Web/NET45/ImageProcessor.Web_NET45.csproj
@@ -32,6 +32,10 @@
4
+
+ True
+ ..\..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll
+
@@ -53,6 +57,7 @@
+
@@ -66,6 +71,9 @@
ImageProcessor
+
+
+
-
+
-
-
+
+
-
+
@@ -41,16 +41,9 @@
-
-
-
-
-
-
-
@@ -60,8 +53,6 @@
-
-
-
+
diff --git a/src/packages/repositories.config b/src/packages/repositories.config
index da0c4374a..a6a409bc3 100644
--- a/src/packages/repositories.config
+++ b/src/packages/repositories.config
@@ -1,6 +1,7 @@
+