REST WCF service and Session‏ in ASP.NET

Please help if you can.

I have been trying to access the current session object of an application from within a WCF REST service.

There has been no success at all. the session object accessed from the service is not the same one in the aspx pages.

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

The code has the following points:

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

in web.config:

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

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

Thank you,


In order for a session to be rehidrated, you need to supply a key. In a normal application that key is supplied by user either via cookie or url parameter.

How are you planning to acquire that key from the REST client? How those clients get that key initially after the authentication? Where they store the key?

This is why most of the REST based services take a api access key and also another key to sign every request.

IMHO sessions are irrelevant in REST based designs.

Need Your Help

Print Web Server Crystal Report into user's Printer

c# printing crystal-reports crystal-reports-2010

I have web application and i am using SAP Crystal report with VS 2010.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.