asp.net-core - AspNetCore 中的 CreatePerOwinContext 替换是什么?

标签 asp.net-core asp.net-identity

AspNetCore 中的 CreatePerOwinContext 替代品是什么(如果有)?

我正在尝试将 Asp.Net Identity 示例迁移到 AspNet Core,并发现遗留问题?提供CreatePerOwinContext扩展方法的包与Asp.Net Core框架不兼容。

最佳答案

经过一番挖掘...似乎 CreatePerOwinContext 主要是依赖注入(inject)机制的一部分。

Microsoft.AspNetCore 1.0.0 作为一等公民支持依赖注入(inject)。

https://docs.asp.net/en/latest/fundamentals/dependency-injection.html

扩展可用于大多数所需的常见身份服务。例如,下面是 CreatePerOwinContextIServiceCollection

的比较

IServiceCollection(AspNetCore 1.0.0)

public class Startup
{
    public void ConfigureServices(IServiceCollection services)
    {
        services.AddDbContext<ApplicationDbContext>(options =>
            options.UseSqlServer(config.GetConnectionString("DefaultConnection")));
    }
}

CreatePerOwinContext(已过时)

public class Startup
{
    public void Configuration(IAppBuilder app)
    {
        app.CreatePerOwinContext(ApplicationDbContext.Create);
    }
}

关于asp.net-core - AspNetCore 中的 CreatePerOwinContext 替换是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38810310/

相关文章:

c# - ASP.NET Core 2.0 禁用自动质询

asp.net-core - Swashbuckle.AspNetCore : 'No operations defined in spec!' problem after update of 'Microsoft.AspNetCore.Mvc.ApiExplorer' package to 2. 2.0

Asp.Net Identity - 不区分大小写的电子邮件和用户名

asp.net - ASP.Net身份-使用自定义架构

asp.net - Asp Core身份,登录后如何获取userId?

c# - 在负载均衡器后面运行的 Identity Server 4

ASP.NET Identity 2 在 cookie 身份验证后执行代码

asp.net - BLAZOR + MVC - 将数据从 Blazor 页面传递到 MVC Controller

c# - 在.Net Core/EF Core中设置多个同一类的外键

c# - 池化的 HttpClient 实例是否保留 CookieContainer?