WCF, ASP.NET sharing session when WCF is called from flash
I've followed the advice in various places, including other questions posted on stackoverflow about sharing the session state between 开发者_如何学Ca WCF service and an ASP.NET website, but cannot get my specific scenario to work:
The website and WCF service are both virtual directories of the same application in IIS 7 and both share an app pool. The website stores some data into the session. A flash object rendered on the client makes a call to the WCF service. I would like the WCF service to be able to access the data in the session.
I have put the [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)] attribute on the service class, and I have the following lines in the web.config for the service:
and on the binding I have allowCookies="true".
All server side code is written in C#.
However, when using HttpContext.Current.Session from the WCF service, I find that there are no keys stored in the session object.
I have checked with Fiddler, and the flash object definitely passes through the ASP.NET_SessionId with the same value as requests to the website from the browser use.
Can anyone shed any light onto how I can make this scenario work?
Thanks.
Check this: http://msdn.microsoft.com/en-us/library/ms731193.aspx
精彩评论