asp.net-mvc-4 – 如何使用业务标识提供程序(例如ADFS2)
我正在运行Win 7,IIS 7.0,VS2012
我创建了asp.mvc4网络应用程序 我在一个单独的VM上安装了ADFS2.0 使用VS 2012中的Identity and Access工具 我选择使用业务标识提供程序(例如ADFS2)并键入STS元数据文档的URL. https://server.local/federationmetadata/2007-06/federationmetadata.xml 编辑了Web配置 <system.web> ... <httpModules> ... <remove name="FormsAuthentication" /> </httpModules> </system.web> 还有这个 <system.webServer> ... <modules> ... <remove name="FormsAuthentication" /> </modules> </system.webServer> 还检查了为项目禁用了Windows身份验证 该网站重定向到这样的URL http:// localhost /WebSite/login.aspx?ReturnUrl=/WebSite/,其中包含“无法找到资源”错误. 我还有什么可以帮助你做这项工作? 微软doco是轻量级的http://blogs.msdn.com/b/vbertocci/archive/2012/03/15/windows-identity-foundation-tools-for-visual-studio-11-part-iii-connecting-with-a-business-sts-e-g-adfs2.aspx 我已经遇到过与本地开发STS MS Identity and Access Tool MVC 4类似的问题 解决方法
好的,这花了我几天的时间来解决,但这些是我为了让它运行而做的事情.还有很多工作要做.
先决条件: >在域上运行的ADFS 2.0服务. 论发展工作站 在你的MVC4项目中 >右键单击Web项目,打开“身份和访问”对话框. 将以下代码添加到项目中 using System; using System.IdentityModel.Services; namespace NAMESPACE { public class FixedWsFederationAuthenticationModule : WSFederationAuthenticationModule { public override void RedirectToIdentityProvider(string uniqueId,string returnUrl,bool persist) { //This corrects WIF error ID3206 "A SignInResponse message may only redirect within the current web application:" //First Check if the request url doesn't end with a "/" if (!returnUrl.EndsWith("/")) { //Compare if Request Url +"/" is equal to the Realm,so only root access is corrected //https://localhost/AppName plus "/" is equal to https://localhost/AppName/ //This is to avoid MVC urls if (String.Compare(System.Web.HttpContext.Current.Request.Url.AbsoluteUri + "/",base.Realm,StringComparison.InvariantCultureIgnoreCase) == 0) { //Add the trailing slash returnUrl += "/"; } } base.RedirectToIdentityProvider(uniqueId,returnUrl,persist); } } } 在ADFS 2.0服务器上 >如果您使用自签名证书,请导航到您的Web应用程序https:// {WEB APPLICATION URL} /并将区域更改为可信站点. 添加一些自定义规则 MVC4需要这些规则才能生成可用的ClaimsPrincipal 在Name属性上添加传递规则. 而这两个自定义规则 => issue(Type = "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier",Value = "true"); => issue(Type = "http://schemas.microsoft.com/accesscontrolservice/2010/07/claims/identityprovider",Value = "true"); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- ASP.NET MVC中使用区域时的配置错误4
- ASP.NET:更好地在资源或数据库中存储可本地化的UI文本?
- Azure Event Hub 技术研究系列2-发送事件到Event Hub
- asp.net-mvc – 从客户端检测到潜在危险的Request.Form值
- asp.net-mvc – 无法导出Kendo Grid中的隐藏列
- asp.net-mvc – 提供DDD,但需要一些其优点
- ASP.NET缓存方法分析和实践示例代码
- asp.net-mvc – 过滤Kendo UI MVC Grid时的自定义谓词构建
- asp.net – 实体框架第一次加载速度很慢
- Asp.Net(MVC):哪个会话超时是什么?