1

是否可以设置 Windows Identity Foundation 回发页面的样式?

这是您成功登录后显示为空白的页面,网址类似于https://sts.address.com/?wa=wsignin1.0&wtrealm=https....

4

2 回答 2

2

我阅读了以下文章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)

于 2011-07-29T09:36:55.110 回答
1

我不知道这是否是一个记录的功能,但我会建议以下作为起点:

如果您的代码看起来与我的完全一样,那么您的代码行如下所示:

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)

如果传入 ,myResponseProcessSignInResponse抛出以下异常:

System.NullReferenceException:对象引用未设置为对象的实例。在 System.Web.HttpResponse.End() 在 Microsoft.IdentityModel.Web.FederatedPassiveSecurityTokenServiceOperations.ProcessSignInResponse(SignInResponseMessage signInResponseMessage, HttpResponse httpResponse) 在 Logon_App.LCLoginBase.issueTokenAndRedirect(logonParamsStruct& logonParams) 在 C:\Logon App\Logon App\Code\LCLogin \LCLoginBase.vb:第 xxx 行

于 2010-07-27T21:02:19.847 回答