When running my project on my DiscountAsp.Net Windows 2008 Server w/ IIS7 and .Net 4.0 I'm not able to access the current username w/ a call to OperationContext.Current.ServiceSecurityContext.PrimaryIdentity.Name. Trying to do so results in a System.NullReferenceException: Object reference not set to an instance of an object exception. I've checked my Web.config and other settings time and time again and haven't found any reasonable explanation for this as I know OpeartionContextExtensions was meant to fix this problem.
Interestingly enough I tried the hack in which you decode and parse the Authentication Headers to get the username/password and this worked sometimes, but other times lead to the exact same error using the exact same request in fiddler.
One thing I found especially interesting was that once it did get the username correctly using this method, requests afterward also seamed to work. However, Session State was disabled in IIS Manager the whole time. I need to access the username 100% of the time however so even this is not good enough.
When running my project on my DiscountAsp.Net Windows 2008 Server w/ IIS7 and .Net 4.0 I'm not able to access the current username w/ a call to OperationContext.Current.ServiceSecurityContext.PrimaryIdentity.Name. Trying to do so results in a System.NullReferenceException: Object reference not set to an instance of an object exception. I've checked my Web.config and other settings time and time again and haven't found any reasonable explanation for this as I know OpeartionContextExtensions was meant to fix this problem.
Interestingly enough I tried the hack in which you decode and parse the Authentication Headers to get the username/password and this worked sometimes, but other times lead to the exact same error using the exact same request in fiddler.
One thing I found especially interesting was that once it did get the username correctly using this method, requests afterward also seamed to work. However, Session State was disabled in IIS Manager the whole time. I need to access the username 100% of the time however so even this is not good enough.