【发布时间】:2011-07-29 21:32:50
【问题描述】:
是否可以设置 Windows Identity Foundation 回发页面的样式?
这是您成功登录后的空白页面,网址类似于https://sts.address.com/?wa=wsignin1.0&wtrealm=https....
【问题讨论】:
是否可以设置 Windows Identity Foundation 回发页面的样式?
这是您成功登录后的空白页面,网址类似于https://sts.address.com/?wa=wsignin1.0&wtrealm=https....
【问题讨论】:
我阅读了以下文章,http://www.paraesthesia.com/archive/2011/01/31.aspx,这使我在 Microsoft.IdentityModel 程序集上使用了 dotPeek。这告诉我所有ProcessSignInResponse 消息的作用如下:
public static void ProcessSignInResponse(SignInResponseMessage signInResponseMessage, HttpResponse httpResponse)
{
if (signInResponseMessage == null)
throw DiagnosticUtil.ExceptionUtil.ThrowHelperArgumentNull("signInResponseMessage");
else if (httpResponse == null)
{
throw DiagnosticUtil.ExceptionUtil.ThrowHelperArgumentNull("httpResponse");
}
else
{
signInResponseMessage.Write(httpResponse.Output);
httpResponse.Flush();
httpResponse.End();
}
}
signInResponseMessage.Write 方法执行以下操作:
public override void Write(TextWriter writer)
{
if (writer == null)
{
throw DiagnosticUtil.ExceptionUtil.ThrowHelperArgumentNull("writer");
}
else
{
this.Validate();
writer.Write(this.WriteFormPost());
}
}
如您所见,本质上,所执行的只是将WriteFormPost的内容写入响应流。
因此,正如我们所说,我正在更改我的“ProcessSignIn”方法以返回要输出的 HTML,而不是调用 FederatedPassiveSecurityTokenServiceOperations.ProcessSignInResponse。
所以,我从本质上改变了我的方法:
public static void ProcessSignIn(SignInRequestMessage signInRequest, HttpResponse httpResponse)
{
FederatedPassiveSecurityTokenServiceOperations.ProcessSignInResponse(signInResponseMessage, httpResponse);
}
收件人:
public static string ProcessSignIn(SignInRequestMessage signInRequest)
{
return signInResponseMessage.WriteFormPost();
}
当然,SignInResponseMessage 应该提供一种更简洁的方法,只返回您想要写入表单帖子的“主要”内容,但获取
作为字符串的 HTML 表单至少可以更轻松地在使用 Response.Write(result) 将结果返回给客户端之前修改结果。
【讨论】:
我不知道这是否是一个记录的功能,但我会建议以下作为起点:
如果您的代码看起来与我的完全一样,那么您的代码行如下所示:
FederatedPassiveSecurityTokenServiceOperations.ProcessSignInResponse(responseMessage, HttpContext.Current.Response)
ProcesssignInResponse 的第二个参数是一个 HttpResponse 对象。我尝试通过传递自定义 HttpResponse 消息以捕获输出以便我们可以随心所欲地对其进行操作,从而找到您问题的答案,但未成功:
Dim myStringbuilder As New StringBuilder
Dim myStringWriter As New IO.StringWriter(myStringbuilder)
Dim myResponse As New Web.HttpResponse(myStringWriter)
如果将myResponse传递给ProcessSignInResponse,则会抛出以下异常:
System.NullReferenceException:对象引用未设置为对象的实例。 在 System.Web.HttpResponse.End() 在 Microsoft.IdentityModel.Web.FederatedPassiveSecurityTokenServiceOperations.ProcessSignInResponse(SignInResponseMessage signInResponseMessage,HttpResponse httpResponse) 在 C:\Logon App\Logon App\Code\LCLogin\LCLoginBase.vb:line xxx 中的 Logon_App.LCLoginBase.issueTokenAndRedirect(logonParamsStruct& logonParams)
【讨论】: