【发布时间】:2014-04-24 16:15:36
【问题描述】:
我将部署我的第一个基于 WCF 的应用程序,并且想知道最好的部署方式。这是我的架构。请看附图。
我们有一个使用 4.0 框架编写的 WCF,并且有 3 个方法。前端 ASP.NET 网站 (www.site.com) 调用 WCF 来保存数据以及读取数据。图中method1是保存到数据,method2和3是从SQL server 2008 R2数据库读取数据。
在我的 ASP.Net 网站中...
我正在调用 Method1 并关闭连接......就像这样......
ServiceClient client = new ServiceClient(); client.Method1(data to be saved) client.close();我调用方法2和3如下
ServiceClient client = new ServiceClient(); dropDown1list.datasource = client.Method2() dropDown2list.datasource = client.Method3() client.close();
多个用户可以同时使用该网站来提交数据。考虑到这种架构......部署 WCF 以便它可以同时处理多个用户的最佳方式是什么?我阅读了文章http://www.codeproject.com/Articles/89858/WCF-Concurrency-Single-Multiple-and-Reentrant-and 和http://www.codeproject.com/Articles/86007/ways-to-do-WCF-instance-management-Per-call-Per。
我现在认为我需要将 WCF 服务作为
[ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Multiple , InstanceContextMode = InstanceContextMode.PerCall )]
public class Service : IService
{
public bool Method1(data to be saved)
{
}
public List<string> Method2()
{
}
public List<string> Method2()
{
}
}
我说的对吗?有什么建议么 ?。
【问题讨论】:
-
在Code Review 上问这个问题可能会更好
标签: c# asp.net wcf concurrency multiple-instances