WCF or ASP for query string edit


I need to write a small application that creates an external url with the windows user name in the query string, then redirects the user to the url.

I thought that a WCF service is not the right way to go, because it says this about WCF on the MSDN link below:

"HttpContext: Current  is always null when accessed from within a WCF service."

at http://msdn.microsoft.com/en-us/library/aa702682.aspx

But, I wanted to verify with someone, because I'm always looking for an excuse to get more experience writing WCF services.

Also, I found at this link: http://www.codeproject.com/KB/aspnet/How_to_NT_User_Name.aspx,
that there are more ways than httpcontext to get the user name:

using three ways we can get the User Name using C#

1) System.Security.Principal.WindowsPrincipal p = System.Threading.Thread.CurrentPrincipal as System.Security.Principal.WindowsPrincipal;

string strName = p.Identity.Name;

[ OR ]

2) string strName = HttpContext.Current.User.Identity.Name.ToString();

[ OR ]

3) string strName = Request.ServerVariables["AUTH_USER"]; //Finding with name

string strName = Request.ServerVariables[5]; //Finding with index

In Above 3 Cases returnin string contains DomainName\WinNTLoggedUserName

(for Ex: Microsoft\Bill.Gates. Here Microsoft is domain Bill.Gates is Logger User Name )

Using string operations seperate the DomainName and UserName.

Could any of these ways work with a WCF service?


Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

ApexCoConnect With a Mentor Commented:
1 & 2 will definitely work with WCF, I'm not sure about #3 though.
Bill732Author Commented:
I thought httpcontext won't work in WCF as stated here:


It reads...

Within an AppDomain, features implemented by the HTTP runtime apply to ASP.NET content but not to WCF. Many HTTP-specific features of the ASP.NET application platform do not apply to WCF Services hosted inside of an AppDomain that contains ASP.NET content. Examples of these features include the following:

    * HttpContext: Current is always null when accessed from within a WCF service.

    * File-based authorization: The WCF security model does not allow for the access control list (ACL) applied to the .svc file of the service when deciding if a service request is authorized.

    * Configuration-based URL Authorization: Similarly, the WCF security model does not adhere to any URL-based authorization rules specified in System.Web’s <authorization> configuration element. These settings are ignored for WCF requests if a service resides in a URL space secured by ASP.NET’s URL authorization rules.

    * HttpModule extensibility: The WCF hosting infrastructure intercepts WCF requests when the PostAuthenticateRequest event is raised and does not return processing to the ASP.NET HTTP pipeline. Modules that are coded to intercept requests at later stages of the pipeline do not intercept WCF requests.

    * ASP.NET impersonation: By default, WCF requests always runs as the IIS process identity, even if ASP.NET is set to enable impersonation using System.Web’s <identity impersonate=”true” /> configuration option.

...I might be misunderstanding it...
Bill732Author Commented:
I found some more information at this link:


Would I need to use WCF in ASP.NET compatibility mode?
Bill732Author Commented:
Thanks for pointing me in the right direction. Looks like this is true as long as you run the WCF in ASP.NET Compatibility Mode.
All Courses

From novice to tech pro — start learning today.