asp.net-mvc 带有 asp.net mvc 应用程序的 WCF 服务

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/943712/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-07 23:37:49  来源:igfitidea点击:

WCF Service with asp.net mvc application

asp.net-mvcwcf

提问by Miral

I have started using asp.net MVC and as traditional way I want to keep my data access layer in WCF service. How can I achieve that using asp.net MVC ?

我已经开始使用 asp.net MVC,作为传统方式,我想将数据访问层保留在 WCF 服务中。如何使用 asp.net MVC 实现这一目标?

Scenario

设想

I started a test application in asp.net MVC which Displays, Inserts and Edit data. I successfully created that by adding 'ADO.Net Entity Data Model'.

我在 asp.net MVC 中启动了一个测试应用程序,它显示、插入和编辑数据。我通过添加“ADO.Net 实体数据模型”成功创建了它。

So now if I wanted to move this dataaccess layer in WCF service, i.e. a WCF service with methods like GetData(), UpdateData(), CreateNewData(), how can i achieve that?

所以现在如果我想在 WCF 服务中移动这个数据访问层,即一个 WCF 服务,它有像 GetData()、UpdateData()、CreateNewData() 这样的方法,我该如何实现呢?

回答by mundeep

Short Answer:

简答:

You just need to move your dataaccess layer into a WCF service, expose it and then call it from your MVC application.

您只需要将数据访问层移动到 WCF 服务中,公开它,然后从您的 MVC 应用程序中调用它。

Long Answer:

长答案:

1) I recommend going through Scott Guthrie's Nerd Dinnerwalkthrough to get a really good understanding of MVC basics.

1) 我建议通过 Scott Guthrie 的Nerd Dinner演练来真正了解 MVC 基础知识。

2) The following blog goes through the process of writing a Layered ASP.NET MVC Applicaiton with a WCF Service (Parts III & IV specifically concentrate on WCF & MVC interaction):

2) 以下博客介绍了使用 WCF 服务编写分层 ASP.NET MVC 应用程序的过程(第三和第四部分专门介绍 WCF 和 MVC 交互):

I haven't read the linked arrticles in detail (just skimmed them) but they seem to give a decent overview of the process.

我没有详细阅读链接的文章(只是略读了它们),但它们似乎对这个过程给出了一个不错的概述。

回答by ran