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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

1 & 2 will definitely work with WCF, I'm not sure about #3 though.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.