【发布时间】: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