开发者

WCF REST breaking when authenticated

I have a very simple WCF REST Service

[ServiceContract]
[AspNetCompatibilityRequirements(
    RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]
public class TestService
{
    [Description("Test Description.")]
    [WebGet(UriTemplate = "go")]
    public string Test()
    {
        return "hi2u";
    }
}

It is c开发者_StackOverflow社区onfigured in the web config like this:

<system.webServer>
    <validation validateIntegratedModeConfiguration="false"/>
    <modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
<standardEndpoints>
  <webHttpEndpoint>
    <standardEndpoint name=""
                                                helpEnabled="true"
                      automaticFormatSelectionEnabled="false"
                                                defaultOutgoingResponseFormat="Json"
                                                crossDomainScriptAccessEnabled="true" />
  </webHttpEndpoint>
</standardEndpoints></system.serviceModel>

The route is then bound with the global.asax

The problem is that if I authenticate to the application using forms authentication then every time I rebuild the solution and try to go to the service the service breaks with the dreaded Request Error page. If I logout and re-run the application it works fine. I will be using the thread principal at some point so I was wondering how to allow my user to be authenticated via forms authentication while still hitting the service?


This post could be helpful. Passing FormsAuthentication cookie to a WCF service

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜