WCF REST Service and Session in ASP.NET

Please help if you can.

I am trying to access the current asp.net application session object from WCF REST service.

There were no successes. the session object accessible from the service is not the same as on aspx pages.

So, here is my question: is it possible to access the current session in the WCF REST service through HttpContext.Current.Session?

The code has the following items:

 [AspNetCompatibilityRequirements
(RequirementsMode = 
AspNetCompatibilityRequirementsMode.Allowed)] // I have also tried Required
public class DataService : IDataService

in web.config:

<system.serviceModel>
  <behaviors>
   <endpointBehaviors>
    <behavior name="ClosedRoom.DataServiceBehavior">
     <enableWebScript />
    </behavior>
   </endpointBehaviors>
  </behaviors>
  <serviceHostingEnvironment aspNetCompatibilityEnabled="true" >
  <baseAddressPrefixFilters>
        <add prefix="http://localhost:63399"/>
      </baseAddressPrefixFilters>
    </serviceHostingEnvironment>

  <services>
    <service name="ClosedRoom.DataService">
      <endpoint address="" behaviorConfiguration="ClosedRoom.DataServiceBehavior"
        binding="webHttpBinding" contract="ClosedRoom.IDataService" />
    </service>
  </services>
</system.serviceModel>

Thank,

+5
source share
2 answers

To re-confirm the session you need to provide a key. In a normal asp.net application, this key is provided by the user through the cookie or url parameter.

REST? ? ?

REST api, .

REST.

+4

, , wcf asp.net, :

[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]

, :

HttpContext: WCF, ASP.NET, .

: AspNetCompatibilityRequirements?

+1

All Articles