ASP.NET MVC和WCF [英] ASP.NET MVC and WCF

查看:190
本文介绍了ASP.NET MVC和WCF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的工作我的方式到MVC的时刻,但对我的要了解在某一时刻名单,我也有WCF。

I'm working my way into MVC at the moment, but on my "To learn at some point" list, I also have WCF.

我只是想知道WCF是什么,应该/可以在MVC应用程序或不能使用?其背景是,我想要一个桌面应用程序(.NET 3.5,WPF)和我的MVC的Web站点进行交互,我不知道什么是最好的方式,在两者之间传输数据。我应该用特殊的视图/有控制器返回JSON或XML(使用ContentResult类型)?

I just wonder if WCF is something that should/could be used in an MVC Application or not? The Background is that I want a Desktop Application (.NET 3.5, WPF) interact with my MVC Web Site, and I wonder what the best way to transfer data between the two is. Should I just use special Views/have the controllers return JSON or XML (using the ContentResult)?

也许更重要的是,对于反过来,可能只需要调用专用控制器?不知道授权是如何工作在这样的背景。我既可以使用Windows身份验证或者(如果该站点运行窗体身份验证),让用户存储在应用程序中他/她的凭据,但我会那么基本上在我的应用程序中创建一个HTTP客户端。因此,尽管MVC =>应用程序似乎很容易,应用=> MVC似乎是有点棘手和可能使用WCF?

And maybe even more important, for the other way round, could I just call special controllers? Not sure how Authorization would work in such a context. I can either use Windows Authentication or (if the Site is running forms authentication) have the user store his/her credentials in the application, but I would then essentially create a HTTP Client in my Application. So while MVC => Application seems really easy, Application => MVC does seem to be somewhat tricky and a possible use for WCF?

我并不想穷举WCF在这一点,但我只是不知道是否有确实是一个很好的用例WCF在MVC应用程序。

I'm not trying to brute-force WCF in this, but I just wonder if there is indeed a good use case for WCF in an MVC application.

推荐答案

WCF服务可能是有意义的在这种情况下,但不创建与您的用户界面保持一致,创建与业务流程保持一致的服务服务。 IE浏览器。你不会有一个返回视图数据的每一页服务,你将有一个公开的逻辑操作的服务。然后,你的网站可以调用Windows客户端调用相同的服务,但你也不必对夫妇Windows客户端的设计到网站的设计。

WCF services might make sense in this situation, but don't create services that align with your UI, create services that align with the business processes. ie. you won't have a service that returns the view data for each page, you will have a service that exposes logical operations. Then, your site can call the same services that the windows client calls, but you don't have to couple the design of the windows client to the design of the web site.

Windows客户端 - >服务 - >网站

Windows Client -> Services -> Web Site

这应该是:

Windows客户端 - >服务

Windows Client -> Services

网站 - >服务

这篇关于ASP.NET MVC和WCF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆