【发布时间】:2013-02-13 23:55:51
【问题描述】:
我有以下场景:
- 与 Silverlight 应用位于同一站点的 WCF 服务(称为“数据服务”)
- WCF 服务和 Silverlight 主机页面所在的网站受到表单身份验证的保护
- WCF 服务位于允许匿名访问的文件夹中
- Silverlight 托管页面位于不允许匿名访问的文件夹中
- 当用户通过表单身份验证登录时,Silverlight 应用程序变得可访问,当调用 WCF/数据服务时,WCF 服务正确地看到表单身份验证用户。
总体而言,此设置效果很好。但是,我们正在调用需要基本身份验证的第三方 REST 服务,并且我们正在使用 RestSharp 来调用该服务。该代码的一个示例是:
Dim url As String = ServicePrefix & ServiceBaseAddress
Dim client As New RestSharp.RestClient(url)
client.Authenticator = New HttpBasicAuthenticator(AccountSID, AuthToken)
Dim request As New RestSharp.RestRequest("Accounts/" & AccountSID & "/SMS/Messages.xml", RestSharp.Method.POST)
request.AddParameter("From", fromPhone)
request.AddParameter("To", toPhone)
request.AddParameter("Body", message)
syncContext = SynchronizationContext.Current
Dim ia = client.ExecuteAsync(request, AddressOf HandleSMSResponse)
在第三方服务调用成功返回,并且我们的消息被发送后,Silverlight 不再在 HttpContext 中发送正确的用户,因此 WCF 服务不再识别表单身份验证用户。
我们目前的想法是 RestSharp 正在控制一些不应该或没有正确恢复状态的东西。有谁知道安全凭证在 Silverlight 中的存储位置,以便我们在调用 RestSharp 之前获取它们并在之后恢复它们?
感谢您的意见!
【问题讨论】:
标签: wcf silverlight-5.0 restsharp