简体   繁体   English

新的ASP.Net MVC项目的体系结构

[英]Architecture for new ASP.Net MVC Project

I am at the start of a new project but I am not sure about some architectural choices. 我正在一个新项目的开始,但是我不确定某些架构选择。 I was hoping that you guys could share me your vision on this. 我希望你们能与我分享您对此的看法。

The client wants an internal website to manage their clients, projects, stock/products,… Next to this they also want a website for their clients where they can view the products and order them. 客户想要一个内部网站来管理他们的客户,项目,库存/产品等。此外,他们还希望为客户提供一个网站,供他们查看产品和订购产品。 So for the external website only a small part of the db will be queried while the internal website will be much bigger. 因此,对于外部网站,仅查询数据库的一小部分,而内部网站则查询得多。

At first I was thinking about using a WCF service for all businesslogic and repository. 最初,我在考虑将WCF服务用于所有业务逻辑和存储库。 But now I am not sure since I know that only a small portion of the actual logic will be used for the external part. 但是现在我不确定,因为我知道实际逻辑中只有一小部分将用于外部。

Using WCF as an extra layer always brings a shitload of extra work and complexity to the project. 使用WCF作为额外的层总是给项目带来很多额外的工作和复杂性。 Is it better to just reference the business/repository layer in both website projects or make use of webAPI in the external website? 仅在两个网站项目中都引用业务/存储库层还是在外部网站中使用webAPI更好?

Really I need to hear some other opinions before I decide what to do. 确实,在决定做什么之前,我需要听取其他意见。

There is nothing inherently wrong with going WCF, business layer assembly, or Web API. 使用WCF,业务层组装或Web API本质上没有任何错误。 All have pluses and minuses. 都有优点和缺点。

WCF would make the most sense if you may someday have a many different clients needing access to the data/business logic and these clients may need to communicate differently (ie HTTP, MSMQ, full duplex, etc.) 如果您有一天可能有许多不同的客户端需要访问数据/业务逻辑,并且这些客户端可能需要进行不同的通信(例如,HTTP,MSMQ,全双工等),则WCF最有意义。

Business Layer assembly would make sense if you are quite sure the data/business logic will not need to be accessed by clients other than the 2 web applications you are developing. 如果您确定要开发的2个Web应用程序之外的客户端将不需要访问数据/业务逻辑,则可以使用业务层组装。 That's not to say you're boxed in doing this though either. 但这并不是说您被限制这样做。 You could always start here and later remove reference to the assembly, encapsulate access to the assembly within WCF or Web API, and then reference WCF or Web API from web applications. 您总是可以从这里开始,以后再删除对程序集的引用,在WCF或Web API中封装对程序集的访问,然后从Web应用程序中引用WCF或Web API。

Web API is a good choice for several reasons. Web API是一个不错的选择,原因有几个。 It provides the ability for many different clients access to the data/business logic without all of the overhead that comes with WCF. 它为许多不同的客户端提供了访问数据/业务逻辑的能力,而没有WCF附带的所有开销。 Additionally, if you have non .NET clients you need not worry about some of the tweaks you would have to potentially make on WCF bindings. 此外,如果您有非.NET客户端,则不必担心可能需要对WCF绑定进行的一些调整。 You can also take advantage of some of what MVC provides you within the Web API such as model binding and validation. 您还可以利用MVC在Web API中为您提供的一些功能,例如模型绑定和验证。

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

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