【问题标题】:WCF REST breaking when authenticated通过身份验证时 WCF REST 中断
【发布时间】:2011-03-09 00:19:35
【问题描述】:

我有一个非常简单的 WCF REST 服务

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

在 web config 中是这样配置的:

<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>

然后路由与 global.asax 绑定

问题是,如果我使用表单身份验证对应用程序进行身份验证,那么每次我重建解决方案并尝试转到服务时,服务都会因可怕的请求错误页面而中断。如果我注销并重新运行应用程序,它工作正常。我将在某个时候使用线程主体,所以我想知道如何允许我的用户通过表单身份验证进行身份验证,同时仍然访问服务?

【问题讨论】:

    标签: c# asp.net-mvc wcf


    【解决方案1】:

    这篇文章可能会有所帮助。 Passing FormsAuthentication cookie to a WCF service

    【讨论】:

      猜你喜欢
      • 2015-04-14
      • 2011-03-27
      • 1970-01-01
      • 1970-01-01
      • 2012-03-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多