我从我的应用程序的ACS门户下载了示例登录页面,这是一个html文件。 然后,我使用WIF配置了我的应用程序,一切都运行良好。
由于我们需要处理和保存传入的查询字符串,以便稍后在用户登录后可以使用查询字符串,我们需要将html登录页面移动到aspx页面。
问题是,当我将web.config文件中的WIF的颁发者更改为aspx文件时,它会停止工作。当它工作时它看起来像这样:
<certificateValidation certificateValidationMode="None" />
<federatedAuthentication>
<wsFederation passiveRedirectEnabled="true" issuer="http://localhost:81/acstest/WebSiteAdvancedACSLoginPageCode.html" realm="http://localhost:81/acstest/" requireHttps="false" />
<cookieHandler requireSsl="false" />
</federatedAuthentication>
但是当我将其更改为我的aspx页面时,我只是将html页面中的所有代码移动到了,我甚至无法加载页面:
<certificateValidation certificateValidationMode="None" />
<federatedAuthentication>
<wsFederation passiveRedirectEnabled="true" issuer="http://localhost:81/acstest/WebSiteAdvancedACSLoginPageCode.aspx" realm="http://localhost:81/acstest/" requireHttps="false" />
<cookieHandler requireSsl="false" />
</federatedAuthentication>
当我运行配置的aspx文件时,我可以在fiddler中看到有些东西不对,它试图获取,并且不断地将“对象移动到这里:”这是获取请求:
GET http://localhost:81/acstest/WebSiteAdvancedACSLoginPageCode.aspx?wa=wsignin1.0&wtrealm=http%3a%2f%2flocalhost%3a81%2facstest%2f&wctx=rm%3d0%26id%3dpassive%26ru%3d%252facstest%252fWebSiteAdvancedACSLoginPageCode.aspx&wct=2011-11-23T09%3a33%3a30Z HTTP/1.1
Accept: text/html, application/xhtml+xml, */*
Accept-Language: sv-SE
User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)
Accept-Encoding: gzip, deflate
Connection: Keep-Alive
Host: localhost:81
Cookie: ACSChosenIdentityProvider-10001951=Google
最后它会抛出一个异常,即查询字符串太长。 请求的错误和警告:
MODULE_SET_RESPONSE_ERROR_STATUS
模块名 UrlAuthorization
通知 AUTHORIZE_REQUEST
的HTTPStatus 401
HttpReason 未经授权
HttpSubStatus 0
错误码 Åtgärdenralsutförts。 (0x0)
ConfigExceptionInfo
任何反馈或替代解决方案都是有意义的。
答案 0 :(得分:3)
“发行人”应该仍然是ACS,而不是您的网站(除非您实施自己的STS,这看起来不像您想要的)。在WIF配置中发行者== STS。
通过令牌协商(通过重定向发生)保留状态(例如网址等)的最佳候选者是通过 wctx 参数。您可以以编程方式设置它。
请查看此下载中的示例#7:http://www.microsoft.com/download/en/details.aspx?id=27289
章节:http://msdn.microsoft.com/en-us/library/hh446534.aspx来自此 指南:http://msdn.microsoft.com/en-us/library/ff423674.aspx
代码看起来像这样(片段):
var returnUrl = GetReturnUrl(context.RequestContext);
// user is not authenticated and it's entering for the first time
var fam = FederatedAuthentication.WSFederationAuthenticationModule;
var signIn = new SignInRequestMessage(new Uri(fam.Issuer), fam.Realm)
{
Context = returnUrl.ToString(),
Realm = string.Format("https://localhost/f-shipping.7/{0}", organizationName)
};
context.Result = new RedirectResult(signIn.WriteQueryString());