Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions samples/Fornax/Fornax.Server/Global.asax.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ void Application_Start(object sender, EventArgs e)
options.UseOwin();
});

// Register the Entity Framework context needed by the OpenIddict stores.
services.AddScoped(static provider => ApplicationDbContext.Create());

// Create a new Autofac container and import the OpenIddict services.
var builder = new ContainerBuilder();
builder.Populate(services);
Expand Down
14 changes: 12 additions & 2 deletions samples/Fornax/Fornax.Server/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Fornax.Server.Models;
using Autofac;
using Fornax.Server.Models;
using Microsoft.AspNet.Identity;
using Microsoft.AspNet.Identity.Owin;
using Microsoft.Owin;
Expand All @@ -16,7 +17,16 @@ public class Startup
public void Configuration(IAppBuilder app)
{
// Register the Entity Framework context and the user/sign-in managers used by ASP.NET Identity.
app.CreatePerOwinContext(ApplicationDbContext.Create);
//
// Note: while the regular CreatePerOwinContext() method is used to store the Entity Framework
// context in the OWIN environment (so that it can be retrieved by the ASP.NET Identity components),
// the factory used here simply resolves the scoped context from the Autofac container to avoid
// having multiple instances of the same context created for each request. As such, the dispose
// callback action is left empty, as the context will be disposed by Autofac when the request ends.
app.CreatePerOwinContext<ApplicationDbContext>(
createCallback: static (options, context) => Global.Provider.ApplicationContainer.Resolve<ApplicationDbContext>(),
disposeCallback: static (options, context) => { });

app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create);
app.CreatePerOwinContext<ApplicationSignInManager>(ApplicationSignInManager.Create);

Expand Down
5 changes: 5 additions & 0 deletions samples/Mortis/Mortis.Client/Models/ApplicationDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ public ApplicationDbContext()
{
}

public static ApplicationDbContext Create()
{
return new ApplicationDbContext();
}

protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.UseOpenIddict();
Expand Down
3 changes: 3 additions & 0 deletions samples/Mortis/Mortis.Client/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ public void Configuration(IAppBuilder app)
});
});

// Register the Entity Framework context needed by the OpenIddict stores.
services.AddScoped(static provider => ApplicationDbContext.Create());

// Create a new Autofac container and import the OpenIddict services.
var builder = new ContainerBuilder();
builder.Populate(services);
Expand Down
14 changes: 13 additions & 1 deletion samples/Mortis/Mortis.Server/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ public void Configuration(IAppBuilder app)
options.UseOwin();
});

// Register the Entity Framework context needed by the OpenIddict stores.
services.AddScoped(static provider => ApplicationDbContext.Create());

// Create a new Autofac container and import the OpenIddict services.
var builder = new ContainerBuilder();
builder.Populate(services);
Expand All @@ -85,7 +88,16 @@ public void Configuration(IAppBuilder app)
var container = builder.Build();

// Register the Entity Framework context and the user/sign-in managers used by ASP.NET Identity.
app.CreatePerOwinContext(ApplicationDbContext.Create);
//
// Note: while the regular CreatePerOwinContext() method is used to store the Entity Framework
// context in the OWIN environment (so that it can be retrieved by the ASP.NET Identity components),
// the factory used here simply resolves the scoped context from the Autofac container to avoid
// having multiple instances of the same context created for each request. As such, the dispose
// callback action is left empty, as the context will be disposed by Autofac when the request ends.
app.CreatePerOwinContext<ApplicationDbContext>(
createCallback: (options, context) => container.Resolve<ApplicationDbContext>(),
disposeCallback: static (options, context) => { });

app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create);
app.CreatePerOwinContext<ApplicationSignInManager>(ApplicationSignInManager.Create);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@
@Html.AntiForgeryToken()

@* Flow the request parameters so they can be received by the LogoutPost action: *@
foreach (var parameter in Model.Parameters)
foreach (var parameter in string.Equals(Request.HttpMethod, "POST", StringComparison.OrdinalIgnoreCase) ?
from name in Request.Form.AllKeys
from value in Request.Form.GetValues(name)
select new KeyValuePair<string, string>(name, value) :
from name in Request.QueryString.AllKeys
from value in Request.QueryString.GetValues(name)
select new KeyValuePair<string, string>(name, value))
{
<input type="hidden" name="@parameter.Key" value="@parameter.Value" />
}
Expand Down
Loading