From fc5934cb18ee95500166fd0e48f9392266769718 Mon Sep 17 00:00:00 2001 From: nathanrobb Date: Thu, 15 Nov 2018 08:57:59 +1300 Subject: [PATCH 1/2] Added Ninject.Extensions.ContextPreservation as a dependency of OwinHost and SelfHost --- .../Ninject.Web.WebApi.OwinHost.csproj | 1 + .../Ninject.Web.WebApi.Selfhost.csproj | 1 + 2 files changed, 2 insertions(+) diff --git a/src/Ninject.Web.WebApi.OwinHost/Ninject.Web.WebApi.OwinHost.csproj b/src/Ninject.Web.WebApi.OwinHost/Ninject.Web.WebApi.OwinHost.csproj index 60d91fb..9e9cb2d 100644 --- a/src/Ninject.Web.WebApi.OwinHost/Ninject.Web.WebApi.OwinHost.csproj +++ b/src/Ninject.Web.WebApi.OwinHost/Ninject.Web.WebApi.OwinHost.csproj @@ -37,6 +37,7 @@ + diff --git a/src/Ninject.Web.WebApi.Selfhost/Ninject.Web.WebApi.Selfhost.csproj b/src/Ninject.Web.WebApi.Selfhost/Ninject.Web.WebApi.Selfhost.csproj index 56ce20c..a2a6bfe 100644 --- a/src/Ninject.Web.WebApi.Selfhost/Ninject.Web.WebApi.Selfhost.csproj +++ b/src/Ninject.Web.WebApi.Selfhost/Ninject.Web.WebApi.Selfhost.csproj @@ -37,6 +37,7 @@ + From e78e8fa9ad92e1af5cfeb8b943bc3df8fcfe48a4 Mon Sep 17 00:00:00 2001 From: nathanrobb Date: Thu, 15 Nov 2018 09:46:58 +1300 Subject: [PATCH 2/2] Added ContextPreservationModule verifying in OwinHost and SelfHost --- src/Ninject.Web.WebApi.OwinHost/OwinWebApiModule.cs | 6 ++++++ src/Ninject.Web.WebApi.Selfhost/WebApiSelfHostModule.cs | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/src/Ninject.Web.WebApi.OwinHost/OwinWebApiModule.cs b/src/Ninject.Web.WebApi.OwinHost/OwinWebApiModule.cs index ecc79c2..37a4311 100644 --- a/src/Ninject.Web.WebApi.OwinHost/OwinWebApiModule.cs +++ b/src/Ninject.Web.WebApi.OwinHost/OwinWebApiModule.cs @@ -25,6 +25,7 @@ namespace Ninject.Web.WebApi.OwinHost using System.Web.Http; using System.Web.Http.Dependencies; + using Ninject.Extensions.ContextPreservation; using Ninject.Modules; /// @@ -66,6 +67,11 @@ public override void VerifyRequiredModulesAreLoaded() throw new InvalidOperationException("This module requires Ninject.Web.WebAPI extension"); } + if (!this.Kernel.HasModule(typeof(ContextPreservationModule).FullName)) + { + throw new InvalidOperationException("This module requires Ninject.Extensions.ContextPreservation extension"); + } + this.Rebind().To(); this.Kernel.Components.RemoveAll(); diff --git a/src/Ninject.Web.WebApi.Selfhost/WebApiSelfHostModule.cs b/src/Ninject.Web.WebApi.Selfhost/WebApiSelfHostModule.cs index e47e843..1436390 100644 --- a/src/Ninject.Web.WebApi.Selfhost/WebApiSelfHostModule.cs +++ b/src/Ninject.Web.WebApi.Selfhost/WebApiSelfHostModule.cs @@ -26,6 +26,7 @@ namespace Ninject.Web.WebApi.Selfhost using System.Web.Http.Dependencies; using System.Web.Http.SelfHost; + using Ninject.Extensions.ContextPreservation; using Ninject.Modules; using Ninject.Web.Common.SelfHost; using Ninject.Web.WebApi; @@ -54,6 +55,11 @@ public override void VerifyRequiredModulesAreLoaded() throw new InvalidOperationException("This module requires Ninject.Web.WebAPI extension"); } + if (!this.Kernel.HasModule(typeof(ContextPreservationModule).FullName)) + { + throw new InvalidOperationException("This module requires Ninject.Extensions.ContextPreservation extension"); + } + this.Rebind().To(); this.Kernel.Components.RemoveAll();