如何在 WCF 服务中访问 HttpContext.Current.User.Username [英] How to access HttpContext.Current.User.Username in WCF service

查看:23
本文介绍了如何在 WCF 服务中访问 HttpContext.Current.User.Username的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从 WCF 服务中的 Web 应用程序访问 HttpContext.Current.User.Username?

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

推荐答案

通常您不需要 - HttpContext 是一个 ASP.NET 概念并且不适用于 WCF,除非您在打开 ASP.NET 兼容性的情况下运行它.

Generally you don't - HttpContext is an ASP.NET concept and doesn't apply to WCF unless you run it with ASP.NET Compatibility turned on.

如果您想要 WCF 中的当前用户,请使用 ServiceSecurityContext.Current.PrimaryIdentity 或通过 OperationContext.

If you want the current user in WCF then use ServiceSecurityContext.Current.PrimaryIdentity or get the security context via the OperationContext.

这篇关于如何在 WCF 服务中访问 HttpContext.Current.User.Username的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆