WCF服务中操作FormsAuthentication的Cookie

在asp.net 应用程序和WCF服务之间共享FormsAuthentication,默认是不支持的,设置一下非常的简单,只需要两步就可以了:

1、在web.config的system.serviceModel增加一个配置:

<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
</system.serviceModel>

2、为WCF打上标签

[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]

这样在WCF服务上就可以操作cookie了。

 附注:  

WCF UserAuthenticate

欢迎大家扫描下面二维码成为我的客户,为你服务和上云

原文地址:https://www.cnblogs.com/shanyou/p/1561429.html