一千萬個為什麽

搜索

C#客戶端 - 服務器應用程序

我需要編寫一個客戶端 - 服務器應用程序。首先,我要編寫一個應用程序服務器。另外我的應用程序服務器應該連接到數據庫(MS Sql Server)並將數據從它傳送到客戶端應用程序。所以,據我所知,我應該使用WCF。這是個好主意嗎?也許我需要看看別的東西?

最佳答案

Lets start with client-server architecture.
Assuming you have finalized that you need client and server, but have you decided carefully the architecture? I mean what type of server and what type of client you are going to create?

Let's see the options here:

Server
1. What type of hosting you are going to use?
2. What type and how much load your server needs to handle?

Client
1. Type of consumer of your service
2. Do client need to be deployed on local machine or it should be web based?

顯然比上述更令人擔憂。初始設計應盡可能靈活。

So, now lets look at some solutions regarding architecture.
Server:
1. Application Hosted WCF server: Each time you need to manage the server lifecycle. Also, this is not scalable. So if you are looking for scalable architecture, you need to look more.
2. IIS hosted WCF server: This might be a good idea along with some architecture concerns as per your need.
3. Web Method: Obviously this came after WCF, but WCF is still in its place. So the main difference is at What is the difference between an asp.net web method and a wcf service?

Now Client:
1. ASP.NET: This will enable to use a single client app for every platform obviously because of HTML
2. WPF/WinForms: This is going to bit tricky to use as client as you need to deploy the client app on user machine and here comes the data security problem. In former you can directly use SSL or some other way to send data to browser. While in this if you are not using WCF with HTTPS and there are some proprietary data going over wires, it may be concerns.

如果您正在尋找服務器的跨平臺使用情況,則可以使用HTML。

Conclusion:
You can use Server as WCF hosted service (either in IIS or in self contained application) and client as ASP.NET.
-----------------------------
If it is not big enough requirement then you can use ASP.NET as server and then browser as client (No need to create client).
----------------------------
You can create server either as WCF as web methods and deploy the client on user machine.
----------------------------
WCF is nice enough and it can handle your proprietary data types as well.

轉載註明原文: C#客戶端 - 服務器應用程序