WCF并存Asp.net
在asp.net 应用程序和WCF服务之间共享FormsAuthentication,默认是不支持的,设置一下非常的简单,只需要两步就可以了:
1、在web.config的system.serviceModel增加一个配置:
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true" />
</system.serviceModel>
2.为WCF打上标签
using System.ServiceModel.Activation;
namespace SLTelerikReport.Web
{
// 注意: 使用“重构”菜单上的“重命名”命令,可以同时更改代码、svc 和配置文件中的类名“SLService1”。
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class SLService1 : ISLService1
{
public string DoWork()
{
return "Ok";
}
}
}