views:

29

answers:

1

I have both the wcf and asp.net project together in the same project. (I'm running on Azure, so this is more convenient).

I have this set in the web.config:

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

My wcf service is decorated with:

[AspNetCompatibilityRequirements(
    RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]

With those attributes set, shouldn't the HttpContext.Current.User be automatically set for me when I run methods in my wcf service? Currently, HttpContext.Current.User is null and not being set for me automatically.

I thought if I used aspNetCompatibilityEnabled then the Application_AuthenticationRequest method would fire in the Global.asax when the wcf method is executed, but, it does not.

The .aspxauth cookie is getting correctly passed to the wcf service, and I'm able to manually decrypt the cookie and set the current user.

Suggestions of why this is not working the way I expect?

A: 

Are you getting the expected user identity in the

ServiceSecurityContext.Current.PrimaryIdentity

field which is available inside your server method's code?? It should be some form of an IIdentity descendant giving you the user info, if available.

marc_s
'System.ServiceModel.ServiceSecurityContext.Current' is null
Mark E
OK, so you're not officially authenticated against the WCF service... can you show us the server and client side config for your bindings? What kind of WCF security are you using??
marc_s
Ok. I discovered what my issue is, but I don't know how to fix it. I'm using a simple HttpModule (which does a rewritepath) to get rid of the .svc at the end of the service name. As a result of this, Application_AuthenticateRequest does not fire and apparently HttpContext.Current.User does not get set either. Suggestions?
Mark E