REST WCF service and Session‏ in ASP.NET

亡梦爱人 提交于 2019-12-04 09:59:33

In order for a session to be rehidrated, you need to supply a key. In a normal asp.net 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.

Rafi

I know this question was asked a long time ago but this can be achieved by hosting the wcf restful service within an asp.net application and then on the top of your service class add the following attribute:

[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]

This enables many things including:

HttpContext: WCF services running in ASP.NET Compatibility Mode can access Current and its associated state.

See here for more info: What does AspNetCompatibilityRequirements really mean?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!