Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can we implement Session management for WebHttpBinding WCF REST Service?

Tags:

rest

c#

wcf

I have been developing a WCF REST service using webHttpBinding Session mode as required.But I am getting this error always "Contract requires Session, but Binding 'WebHttpBinding' doesn't support it or isn't configured properly to support it." Can any one tell what would be the reason for this ?

like image 448
Hemant Kumar Avatar asked Feb 22 '26 20:02

Hemant Kumar


1 Answers

Quote from the MSDN forums:

You cannot use WebHttpBinding for session based communication as it doesn't support the concept of sessions. I talked at length about sessions here - http://www.dotnetconsult.co.uk/weblog2/PermaLink,guid,af6e6325-2e30-42e3-acb9-57e1363fa51e.aspx.

WebHttpBinding doesn't support session for the same reason BasicHttpBinding doesn't. If you really must have sessions then you will have to use a binding that supports it. However, PerSession activation is only one way to maintain per client state. Can you not use another mechanism, say passing a session id to the service that you use to wire up your own concept of session?

like image 98
stuartd Avatar answered Feb 25 '26 08:02

stuartd



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!