我有一个使用WCF的Silverlight应用程序。我希望能够根据使用该应用程序的Windows用户获得唯一信息;即,我只想显示该用户的数据。该站点将托管在IIS上。我遇到了各种各样的问题......
我最初使用HttpContext.Current
但是当我在IIS中托管它时,它开始变为null(尽管使用了Windows身份验证)。
我的web.config:
<system.web>
<authentication mode="Windows"/>
<system.web>
我唯一想知道的是Silverlight clientconfig详细信息。它的绑定有<security mode="None"/>
,但每当我尝试更改它们时,我都会收到错误。
我目前正在使用basicHttpBinding。
我还为我的服务设置了aspNetCompatibility,因此它应该能够处理HttpContext。
这是我的ServiceReferences.ClientConfig文件:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="winAuthBinding" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="Windows" proxyCredentialType="Windows"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="../service.svc"
binding="basicHttpBinding" bindingConfiguration="winAuthBinding"
contract="Contract1" name="name1" />
<endpoint address="../service.svc"
binding="basicHttpBinding" bindingConfiguration="winAuthBinding"
contract="Contract2" name="name2" />
<endpoint address="../service.svc"
binding="basicHttpBinding" bindingConfiguration="winAuthBinding"
contract="Contract3" name="name3" />
</client>
</system.serviceModel>
和web.config;我只会粘贴system.serviceModel部分:
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="serviceBehaviour">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
<bindings>
<basicHttpBinding>
<binding name="winAuthBinding">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="serviceBehaviour" name="name1">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="winAuthBinding"
contract="Contract1"/>
</service>
<service behaviorConfiguration="serviceBehaviour" name="name2">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="winAuthBinding"
contract="Contract2"/>
</service>
<service behaviorConfiguration="serviceBehaviour" name="name3">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="winAuthBinding"
contract="Contract3"/>
</service>
</services>
<client/>
</system.serviceModel>
答案 0 :(得分:0)
您是否为IIS托管服务配置了<basicHttpBinding>
元素,它应该类似于:
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" />
</security>
答案 1 :(得分:0)
不确定这是否是你需要的,但你试过吗
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession)]
服务类的装饰?