diff --git a/samples/Mvc.Client/Startup.cs b/samples/Mvc.Client/Startup.cs index 555da251..5d9a0614 100644 --- a/samples/Mvc.Client/Startup.cs +++ b/samples/Mvc.Client/Startup.cs @@ -27,6 +27,7 @@ namespace Mvc.Client { }); services.AddMvc(); + services.AddMvcDnx(); } public void Configure(IApplicationBuilder app) { diff --git a/samples/Mvc.Client/project.json b/samples/Mvc.Client/project.json index c9f42a47..a9ad8108 100644 --- a/samples/Mvc.Client/project.json +++ b/samples/Mvc.Client/project.json @@ -1,12 +1,13 @@ { "dependencies": { - "Microsoft.AspNetCore.Mvc": "1.0.0-*", "Microsoft.AspNetCore.Authentication.Cookies": "1.0.0-*", "Microsoft.AspNetCore.Authentication.OpenIdConnect": "0.1.0-*", "Microsoft.AspNetCore.Diagnostics": "1.0.0-*", "Microsoft.AspNetCore.IISPlatformHandler": "1.0.0-*", "Microsoft.AspNetCore.HttpOverrides": "1.0.0-*", "Microsoft.AspNetCore.Hosting": "1.0.0-*", + "Microsoft.AspNetCore.Mvc": "1.0.0-*", + "Microsoft.AspNetCore.Mvc.Dnx": "1.0.0-*", "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*", "Microsoft.AspNetCore.StaticFiles": "1.0.0-*", "Microsoft.Extensions.Logging.Console": "1.0.0-*", diff --git a/samples/Mvc.Server/Startup.cs b/samples/Mvc.Server/Startup.cs index 637d4257..622b0520 100644 --- a/samples/Mvc.Server/Startup.cs +++ b/samples/Mvc.Server/Startup.cs @@ -35,6 +35,7 @@ namespace Mvc.Server { .Build(); services.AddMvc(); + services.AddMvcDnx(); services.AddEntityFramework() .AddSqlServer() diff --git a/samples/Mvc.Server/project.json b/samples/Mvc.Server/project.json index 7c0c7706..f81ddf2f 100644 --- a/samples/Mvc.Server/project.json +++ b/samples/Mvc.Server/project.json @@ -7,6 +7,7 @@ "Microsoft.AspNetCore.Diagnostics": "1.0.0-*", "Microsoft.AspNetCore.IISPlatformHandler": "1.0.0-*", "Microsoft.AspNetCore.HttpOverrides": "1.0.0-*", + "Microsoft.AspNetCore.Mvc.Dnx": "1.0.0-*", "Microsoft.AspNetCore.Mvc.TagHelpers": "1.0.0-*", "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*", "Microsoft.AspNetCore.StaticFiles": "1.0.0-*", diff --git a/src/OpenIddict.Mvc/OpenIddictExtensions.cs b/src/OpenIddict.Mvc/OpenIddictExtensions.cs index 41ef2d7d..f1d18d41 100644 --- a/src/OpenIddict.Mvc/OpenIddictExtensions.cs +++ b/src/OpenIddict.Mvc/OpenIddictExtensions.cs @@ -11,6 +11,8 @@ using JetBrains.Annotations; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc.ApplicationModels; +using Microsoft.AspNetCore.Mvc.Infrastructure; +using Microsoft.AspNetCore.Mvc.Razor.Compilation; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.FileProviders; using OpenIddict; @@ -93,6 +95,26 @@ namespace Microsoft.AspNetCore.Builder { .MakeGenericType(registration.UserType, registration.ApplicationType)); }); + // Register the assembly provider in the isolated container. + services.AddScoped(provider => { + var accessor = provider.GetRequiredService(); + var container = (IServiceProvider) accessor.HttpContext.Items[typeof(IServiceProvider)]; + Debug.Assert(container != null); + + // Resolve the assembly provider from the parent container. + return container.GetRequiredService(); + }); + + // Register the compilation service in the isolated container. + services.AddScoped(provider => { + var accessor = provider.GetRequiredService(); + var container = (IServiceProvider) accessor.HttpContext.Items[typeof(IServiceProvider)]; + Debug.Assert(container != null); + + // Resolve the compilation service from the parent container. + return container.GetRequiredService(); + }); + // Register the options in the isolated container. services.AddScoped(provider => builder.Options); }));