I am looking for WCF sample code with session enabled. When service is hosted needs to be consumed in windows .net application keeping session alive. Along with windows application same service should be easily consume by jquery ajax. We are already using wshttpbinding and session is available for we application but not for windows .net application.
Asked
Active
Viewed 78 times
0
-
1. Sample for WCF with sessions: https://www.codeproject.com/Articles/188749/WCF-Sessions-Brief-Introduction 2. Sample for WCF with JSON: https://www.codeproject.com/Articles/167159/How-to-create-a-JSON-WCF-RESTful-Service-in-60-sec 3. download and combine both examples – Aedvald Tseh Jun 09 '18 at 17:52
-
Gone through both example already. When combined only ajax works but not the session in windows application! – PKK Jun 10 '18 at 04:28
-
Which binding do you use ? BasicHttpBinding or WSHttpBinding ? – Aedvald Tseh Jun 10 '18 at 04:51
-
Possible duplicate of [How can we implement Session management for WebHttpBinding WCF REST Service?](https://stackoverflow.com/questions/21257565/how-can-we-implement-session-management-for-webhttpbinding-wcf-rest-service) – Aedvald Tseh Jun 10 '18 at 05:05
-
wshttpbinding. The constrain is we cannot use tcp binding. – PKK Jun 10 '18 at 05:08
-
If you want to build a WCF-service, which is consumable by jquery ajax, then you need to use binding **WebHttpBinding**. But **WebHttpBinding** does not support sessions. But take a look at this: https://www.codeproject.com/Articles/322436/Maintain-HTTP-Session-State-in-WCF-REST-Services-w – Aedvald Tseh Jun 10 '18 at 05:15
-
I am really surprised that no body had build WCF and .net windows application along with WCF session! – PKK Jun 11 '18 at 09:30
-
Please note that for your new projects, people don"t use anymore WCF. These days devs you use ASP.NET MVC with Web API V2, because then it automatically works with Jquery, AJAX and JSON. Web API V2 supports both XML and JSON as response content type. More here: https://learn.microsoft.com/en-us/aspnet/web-api/overview/getting-started-with-aspnet-web-api/tutorial-your-first-web-api – Aedvald Tseh Jun 11 '18 at 15:55