WCF 服务与 ASP.NET 站点之间的交互问题(具有无 cookie 会话、不同子域)
我有几个 ASP.NET 站点,托管在同一域(不同的子域)上并通过 HTTPS 工作。
我有 WCF 服务,托管在同一域上。
我有一个单独的会话状态服务器。
所有站点都使用 cookieless 会话(如果有人问为什么 - 我稍后会回复,但这是“必须”)
在我的站点上,我使用来自 Telerik 的网格组件(但实际上并不重要),它们从 WCF 服务请求数据并且必须填充这些数据。
问题是:
1)我无法设法从javascript向WCF服务发出POST请求:由于某种原因,它总是GET或OPTIONS(无论我使用Sys.Net.WebServiceProxy调用还是只是一个普通的jquery AJAX请求)。即使我指定COOKIE模式,而不是无cookie,也会发生这种情况。也许正因为如此,我收到“405 Method not allowed”错误 - WCF 设置为 POST 请求,但网站发送 GET...
2) 我无法设法从我的网站检索 SESSION!我尝试了我发现的方法,但 WCF 始终使用 OWN 会话,而不是“连接”到现有 ASP.NET 会话,尽管处于 ASP.NET 兼容模式。我需要 SESSION 在我的站点和 WCF 服务之间交换数据
3) 我目前不知道,鉴于上述问题,如何在上述站点之间交换数据时管理安全性...
4) 我不知道确切地知道,在我的情况下,WCF 服务的 web.config 应该是什么样子,因为我已经看到了大量不同的变体,但都是针对一些简单的情况。
非常感谢您的帮助!我已经被困了 2 或 3 周,远远落后于计划,但仍然没有任何效果...我可以看到有一些关于类似问题的信息,但我担心错过一些小事情 - 在网络中。配置或方法属性或 IIS 设置等 - 然后搞砸一切。
问题太多,实验时间太少:(
I have several ASP.NET sites, hosted on the same domain (different subdomains) and working via HTTPS.
I have WCF service, hosted on the same domain.
I have a separate state server for sessions.
All sites use cookieless session (if someone asks why - i will reply later, but it's a 'must')
On my sites, I use grid components from Telerik (but actually it does not matter) that ask for data from WCF service and must be filled with this data.
The problems are:
1) I cannot manage to make POST request to WCF service from javascript: for some reason it's always either GET or OPTIONS (no matter if I use Sys.Net.WebServiceProxy invoke or just a plain jquery AJAX request). It happens even if I indicate COOKIE mode, not cookieless. Maybe because of this I am getting "405 Method not allowed" error - WCF is set for POST request, but the site sends GET...
2) I cannot manage to retrieve SESSION from my websites! I tried approach, that I found, but WCF always uses OWN session, instead of 'connecting' to existing ASP.NET session, despite on ASP.NET compatibility mode. I need SESSION to exchange data between my sites and WCF service
3) I don't have idea currently, how to manage security when exchanging data between mentioned ones, in the light of above-mentioned problems...
4) I don't know exactly, how web.config for WCF service should look like in my case, because I've seen tons of different variants, but all for some simple cases.
Would be really appreciated for the help! I'm stuck for 2 or 3 weeks already, far behind the plan, but nothing still works... I can see there are some pieces of info about similar problems, but I'm afraid to miss some small thing - in web.config or method attribute or IIS setting, etc - and f... up everything.
Too many problems and too few time for experiments :(
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
嗯,首先:WCF 不是 ASP.NET - 因此,您不能在 ASP.NET 站点和 WCF 之间共享会话状态。
如果您需要在两个世界之间共享任何内容,则应将其存储在双方都可以访问的数据库中。
您没有提供有关您想要执行的操作的大量信息...您能否向我们解释一下 WCF 服务应该做什么(或向我们展示 WCF 服务合同)?另外 - 调用该服务有什么要求?您谈论 POST 请求...您是否正在尝试创建一个从 Javascript 调用的 RESTful 服务?
更新:虽然 WCF 确实不是 ASP.NET,并且两者基本上不使用相同的会话状态等机制,但似乎可以配置 WCF 服务(当托管在IIS)能够访问 ASP.NET 会话状态。
请参阅 Wenlong Dong 的博客文章 使用 WCF 中的 ASP.NET 会话。从他的博客文章中,我不知道这是否会在无 cookie 的环境中工作,但是......
Well, for one: WCF is not ASP.NET - so therefore, you cannot share session state between ASP.NET sites and WCF.
If you need to share anything between the two worlds, it should be stored in a database both sides can access.
You don't provide a whole lot of information about what you're trying to do... can you explain to us what that WCF service should do (or show us the WCF service contract)?? Also - what are the requirements for calling that service? You talk about POST requests... are you trying to create a RESTful service to be called from Javascript?
Update: while it's true that WCF is not ASP.NET, and the two basically don't use the same mechanisms for session state etc., it appears to be possible to configure WCF services (when hosted in IIS) to be able to access ASP.NET session state.
See Wenlong Dong's blog post on Using ASP.NET sessions from WCF. From his blog post, I don't see whether this will work in a cookieless environment, however.....
我最终将 WCF 服务移至 Web 下,因此将拥有一个 WCF 服务 PER 网站
I ended up with moving WCF service under web, so will have a WCF service PER web site
使用此链接当您使用 silverlight 应用程序和 Wcf 服务时,然后使用 coockie less url
http://mithunpatra.blogspot.in/2015 /05/coockie-less-urls-to-access-wcf.html
use this link When you are using silverlight application With Wcf Service then for coockie less url
http://mithunpatra.blogspot.in/2015/05/coockie-less-urls-to-access-wcf.html
当您使用 silverlight 应用程序和 Wcf 服务时,对于 coockie less url
http://mithunpatra.blogspot.in/2015 /05/coockie-less-urls-to-access-wcf.html
When you are using silverlight application With Wcf Service then for coockie less url
http://mithunpatra.blogspot.in/2015/05/coockie-less-urls-to-access-wcf.html