我有一個WCF服務定義爲:WCF服務和AspNetCompatibilityEnabled = 「真」,導致請求錯誤
[ServiceContract]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
public class Service
{
[OperationContract]
[WebGet(ResponseFormat = WebMessageFormat.Json)]
public string HelloWorld()
{
return "Hello World";
}
}
我的web.config文件:
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0"/>
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="webHttpBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<webHttpBinding>
<binding name="webHttpBindingWithJsonP" crossDomainScriptAccessEnabled="true"/>
</webHttpBinding>
</bindings>
<services>
<service name="Service">
<endpoint address="" binding="webHttpBinding" bindingConfiguration="webHttpBindingWithJsonP" contract="Service" behaviorConfiguration="webHttpBehavior"/>
</service>
</services>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true"/>
</system.serviceModel>
</configuration>
我希望能夠訪問ASP .Net會話變量在我的WCF服務中,並且我希望WCF服務能夠返回JSONP數據,但是即使使用這個簡單的服務,瀏覽到../Service.svc/HelloWorld我也收到了400錯誤請求錯誤。
有人能指出我正確的方向嗎?
什麼是詳細的錯誤信息?這可能是ASP.Net兼容性不支持你的綁定的一部分。 – McGarnagle
服務器在處理請求時遇到錯誤。異常消息是「跨域javascript回調在認證服務中不受支持」。 –