ASP.NET MVC &网页服务 [英] ASP.NET MVC & Web Services
问题描述
向我的 ASP.NET MVC 项目添加 Web 服务会破坏 MVC 的整个概念吗?
Does adding a Web Service to my ASP.NET MVC project break the whole concept of MVC?
该 Web 服务 (WCF) 依赖于我的 MVC 项目中的模型层与后端进行通信(因此在我看来它需要成为 MVC 解决方案的一部分).
That Web Service (WCF) depends on the Model layer from my MVC project to communicate with the back-end (so it looks to me like it needs to be part of the MVC solution).
我应该将它添加到控制器层还是模型层?
Should I add this to the Controller or Model layer?
推荐答案
听起来您应该将模型拆分为自己的程序集,并从您的 MVC 应用程序和 WCF 应用程序中引用它.
It sounds like you should split out your model into its own assembly and reference it from your MVC-application and WCF-application.
- YourApp.Data -- 可能共享模型和数据访问
- YourApp.Web -- 如果您想在您的网络应用中分享更多内容
- YourApp.Web.Mvc
- YourApp.Web.WebService
如果你想做 WebServices MVC 风格的,也许你应该使用 MVC 来构建你自己的 REST 应用程序.
If you want to do WebServices MVC-style maybe you should use MVC to build your own REST-application.
这篇关于ASP.NET MVC &网页服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!