asp.net-mvc – 带有owin和Identity的城堡windsor
发布时间:2020-12-16 09:20:21 所属栏目:asp.Net 来源:网络整理
导读:我在使用Identity和城堡windsor的典型asp.net项目中遇到owin配置问题. 事情是我真的喜欢身份和owin如何管理所有用户的东西,如向登录用户发送cookie等等,但它需要以下代码: [assembly: OwinStartupAttribute(typeof(OwinStartUp.Startup))]namespace OwinSta
我在使用Identity和城堡windsor的典型asp.net项目中遇到owin配置问题.
事情是我真的喜欢身份和owin如何管理所有用户的东西,如向登录用户发送cookie等等,但它需要以下代码: [assembly: OwinStartupAttribute(typeof(OwinStartUp.Startup))] namespace OwinStartUp { public partial class Startup { public void Configuration(IAppBuilder app) { app.CreatePerOwinContext(DbOwinHelper.CreateDbContext); app.CreatePerOwinContext<ApplicationUserManager>(DbOwinHelper.CreateUserManager); app.CreatePerOwinContext<ApplicationSignInManager>(DbOwinHelper.CreateSignInManager); app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,LoginPath = new PathString("/Account/Login"),Provider = new CookieAuthenticationProvider { OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager,MyIdentityUser,Guid>( validateInterval: TimeSpan.FromMinutes(30),regenerateIdentityCallback: (manager,user) => user.GenerateUserIdentityAsync(manager),getUserIdCallback: (user) => Guid.Parse(user.GetUserId())) } }); } } } 所以在例如控制器我必须写这个: var signInManager = HttpContext.GetOwinContext().Get<ApplicationSignInManager>(); 而不是这(我喜欢) var signinmanager = container.Resolve<ISignInManager<IMyIdentityUser>>(); 或至少 var signinmanager = container.Resolve<ApplicationSignInManager>(); 我怎样才能将windsor与owin管道整合?或者,至少,如何将CookieAuthentication与我的自定义ApplicationSignInManager一起使用而不使用owin(并且没有重写我自己的整个cookie身份验证)? 我看过很多关于城堡windsor的文章作为owin dependecy resolver,但它主要是关于自我托管owin. 解决方法
好的,所以经过近一年的时间我找到了答案:
WebApi + Simple Injector + OWIN
发表这篇文章:https://simpleinjector.codeplex.com/discussions/539965 我认为这三个问题/答案的结合让我满意. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- .NET Framework 3.5中有哪些有用的新ASP.NET功能?
- .NET Core的日志[3]:将日志写入Debug窗口
- asp.net-mvc – 在存储库之间调用方法 – 存储库模式
- asp.net-mvc – 我可以在asp.net mvc中拥有多个site.master
- ASP.NET 5自定义错误页面无法在Azure网站上呈现
- asp.net-core – 在强类型视图中呈现ViewComponent的Invali
- asp.net – 使用多语言支持的“正确”方式
- asp.net – 关闭Application Insights
- asp.net-core-mvc – 在ASP Net Core 2.0 MVC中检索应用程序
- asp.net-mvc – 实体框架 – 无法创建x类型的常量值.在此上
推荐文章
站长推荐
热点阅读