How to access HttpContext.Current.User.Username in WCF service

后端 未结 2 589
不知归路
不知归路 2020-12-17 10:06

How can I access HttpContext.Current.User.Username from a web application in a WCF service?

2条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-17 10:39

    Actually, with Asp.Net Compatibility mode on, you can access HttpContext.Current.User from a WCF service hosted in the site. See Microsoft's site for details: https://msdn.microsoft.com/en-us/library/aa702682(v=vs.110).aspx

    If your service is hosted in an Asp.net site you just need to update your web.config to set aspNetCompatibilityEnabled="true" on the serviceHostingEnvironment element:

    
      
    
    

提交回复
热议问题