本文介绍了如何在 WCF WebApplication 中维护 Session 和同一个频道的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个 WCF 服务,将它托管在 IIS 中并为其创建了一个 Web 应用程序客户端.

I created a WCF Service, Hosted it in IIS and created a web application client for it.

一切正常.

问题是,当我在 WCF 服务中启用具有所有必需属性的会话时,它创建了一个问题.

problem is, when I enable session in WCF service with all the required attributes it created one problem.

我的服务有几个功能.我想首先执行的功能是我的登录功能,所以我设置了 IsInitiating=true.

My service has several functions. function which I want to execute first is my Login functionality, so i set IsInitiating=true.

和 IsInitiating=false 在所有其他函数上.

and IsInitiating=false on all other functions.

现在从客户端,当我调用登录函数时它工作正常.但是当我在客户端登录后尝试调用其他函数时会产生异常,无法首先调用该函数 XYZ,因为 IsInitiating 设置为 fale;

now from client side it works fine when i call the Login Function. but when i try to call other functions once the client is logged in it generate an exception , that function XYZ can not be call first because IsInitiating is set to fale;

我认为问题是每次当我的页面在服务器上发回时,它都会创建我的 wcf 服务的一个新实例,该实例与服务器建立新的会话.如何为我的 Web 应用程序中的所有事件维护相同的代理?

I think the problem is every time when my page is posted back on the server it created a new instance of my wcf service which establish a new session with the server. how to maintain the same proxy for all the events in my web application?

推荐答案

我有一个非常有趣的链接给你,它可能可以解决你的问题.http://www.codeproject.com/KB/WCF/Sessions_in_WCF.aspx

I have very interesting link for you, which probably could solve your problem.http://www.codeproject.com/KB/WCF/Sessions_in_WCF.aspx

这篇关于如何在 WCF WebApplication 中维护 Session 和同一个频道的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-31 16:36