asp.net-mvc – 在mvc 5和web api 2之间共享owin cookie身份验证
发布时间:2020-12-16 09:41:14 所属栏目:asp.Net 来源:网络整理
导读:我有一个使用web api 2,api的mvc 5应用程序. MVC应用程序使用owin cookie身份验证来验证用户,它工作正常.要求是,如果用户登录MVC应用程序,他还应该能够访问API中的安全方法. 当有asp.net表单auth时,我在API和MVC中使用相同的机器密钥来成功验证api中APP的用
我有一个使用web api 2,api的mvc 5应用程序.
MVC应用程序使用owin cookie身份验证来验证用户,它工作正常.要求是,如果用户登录MVC应用程序,他还应该能够访问API中的安全方法. 当有asp.net表单auth时,我在API和MVC中使用相同的机器密钥来成功验证api中APP的用户.但无法使用owin cookie身份验证. 以下是API和MVC应用程序的auth部分. API HttpConfiguration config = new HttpConfiguration(); WebApiConfig.Register(config); app.UseWebApi(config); app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,}); MVC APP app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,LoginPath = new PathString("/Login") }); 两个项目中的web.configs都输入了相同的机器密钥.任何帮助将非常感激. 解决方法
以下是我的问题.它位于我的WebpiConfig.cs文件中的Register方法中.
config.SuppressDefaultHostAuthentication(); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net – 实体框架第一次加载速度很慢
- asp.net-mvc-3 – MVC 3(Razor) – 使用Button事件调用Cont
- 在ASP.NET 2.0中的特定时间清除缓存
- 用ASP.NET MVC阻止ZmEu攻击
- asp.net – 在iframe中丢失会话状态,但不在弹出窗口中
- asp.net-mvc – 如何测试MVC3 razor布局中是否存在变量?
- asp.net-mvc – 为什么没有参数的POST不返回JSON
- asp.net-mvc – Razor查看引擎在VB.NET中的怪癖
- asp.net – SQL Reporting Services可以与ASP成员资格提供程
- asp.net – 为什么IIS首次访问速度慢,但之后更快?
推荐文章
站长推荐
- 维护面板滚动位置部分回传ASP.NET
- asp.net-mvc – 更正错误后ValidationSummary是否
- 在asp.net应用程序中使用Quartz.Net
- asp.net – 对框架程序集“System.Runtime,Versi
- ASP.NET MVC,AngularJS,Bower和部署站点文件夹结
- asp.net – 压缩不起作用
- asp.net-mvc – 在github中避免使用ASP.NET密码?
- asp.net-mvc – Asp.Net MVC 5如何将ViewBag发送
- dependency-injection – 如何使用ASP.NET MVC 3
- asp.net – 相当于Sitecore中的Razor Section He
热点阅读