【问题标题】:Using ServiceSecurityContext.Current with WCF/Silverlight 4将 ServiceSecurityContext.Current 与 WCF/Silverlight 4 一起使用
【发布时间】:2011-04-04 15:31:26
【问题描述】:

我想为我的 Silverlight 应用程序使用当前的 Windows 用户。使用任何其他应用程序我可以只使用WindowsIdentity,但似乎我需要将ServiceSecurityContext.Current 与WCF 一起使用。我的问题是.Currentnull 出现。

显然这是因为我使用的运输方式。我的问题是 Silverlight 不能使用 TransportWithMessageCredential 显然它不想使用 Https。

所以我尝试使用TransportWithMessageCredential,我的服务开始说它期待 Https,但正在接收 Http。

我在网上四处查看,似乎我需要使用 wsHttpBinding(Silverlight 不提供)或某种形式的访问策略才能将 Https 与 Http 结合使用(这似乎不起作用)。

肯定有更简单的方法来做到这一点?

【问题讨论】:

    标签: c# silverlight wcf


    【解决方案1】:

    我通过做一些事情设法解决了这个问题:

    1) <authentication mode="Windows"/> 在 web.config 文件中

    2) <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" /> 在 web.config 文件中。 aspnetCompatibilityEnabled 在这里很重要。

    3) 我的 WCF 服务类上的 [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] 属性。

    4) 使用HttpContext.Current.User.Identity as WindowsIdentity 获取windows 身份。

    【讨论】:

    • 没有 aspNetCompatibilityEnabled="true" 是否可以做到这一点
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多