简体   繁体   English

通过Ajax在WCF服务调用中出现会话错误

[英]Session error in wcf service call through ajax

I want to know if sessions are maintained through ajax calls. 我想知道会话是否通过ajax调用维护。 I have a Sencha(JS) client which makes ajax GET calls to the server.Server side is implemented using WCF C# .Now when I make the first call the session should start and it seems it is starting. 我有一个Sencha(JS)客户端,它向服务器发出Ajax GET调用。服务器端是使用WCF C#实现的。现在,当我进行第一个调用时,会话应该开始并且似乎正在启动。 but when the application is making the next call which needs the server to retrieve some value from session which it saved in the first call i am getting an error.As the first call where the session is getting set is nt throwing error so I believe session is getting started. 但是当应用程序进行下一个调用时,需要服务器从它保存在第一次调用中保存的会话中检索一些值时,我得到了一个错误。由于设置了会话的第一次调用是nt抛出错误,所以我相信会话正在开始。 But in the 2nd call it is throwing error. 但是在第二次通话中,它会引发错误。

POINT TO BE NOTED : This is only happening when calling through application. 要点:仅在通过应用程序调用时才会发生。 If I am calling simply hitting the GET url in browser everything working perfectly. 如果我打电话只是在浏览器中点击GET网址,那么一切运行正常。

Please help what could be the reason. 请帮助可能是什么原因。 I am at a loss. 我很茫然。

Sessions are mapped using a session cookie. 使用会话cookie映射会话。

You should verify that your application is actually forwarding the session cookie in the call that fails. 您应该验证您的应用程序实际上在失败的呼叫中转发会话cookie。 Enumerate all cookies in the call that works and the call that fails and compare. 枚举有效的呼叫和失败的呼叫中的所有cookie,然后进行比较。

Continued: 继续:

I usually do ajax via a generic handler (.ashx) I use as a facade that in turn calls any sub systems. 我通常通过通用处理程序(.ashx)来执行ajax,我将其用作门面,依次调用任何子系统。 In this handler I do parameter conversion and json (de)serialization. 在此处理程序中,我进行参数转换和json(反)序列化。 Maybe you should go for such an approach and not expose your WCF layer? 也许您应该采用这种方法而不暴露WCF层?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM