[英]Consuming ASP.NET MVC action methods
current situation: an ASP.NET MVC web site with a number of controllers and action methods, and views to allow adding recipes. 当前情况:一个ASP.NET MVC网站,其中包含许多控制器和操作方法,以及允许添加配方的视图。
Now, I have to create a WPF application that acts as a UI to add recipes (same as the web site). 现在,我必须创建一个WPF应用程序,作为添加配方的UI(与网站相同)。
My question is: can I use ASP.NET MVC site to expose service operations that are consumed by the WPF application (and how can this be done)? 我的问题是:我可以使用ASP.NET MVC站点来公开WPF应用程序使用的服务操作(以及如何完成)? Or should I better create dedicated WCF services for that, and have the WPF AND the ASP.NET MVC site consume these services?
或者我应该为此更好地创建专用的WCF服务,并让WPF和ASP.NET MVC站点使用这些服务?
Thanks, Ludwig 谢谢,路德维希
I have successfully used MVC controllers and actions to service both HTML views from the browser, as well as external applications. 我已经成功地使用MVC控制器和操作来为浏览器的HTML视图以及外部应用程序提供服务。 It works well, but as it stands you'd need a little bit of tooling:
它运作良好,但就目前而言,您需要一些工具:
However, you could avoid some of this extra tooling if you go the WCF-REST route. 但是,如果您使用WCF-REST路由,则可以避免一些额外的工具。 Better yet, I'd look into ASP.NET MVC 4's WebApi feature (which is what I will be migrating to).
更好的是,我将研究ASP.NET MVC 4的WebApi功能(我将迁移到这个功能)。
For the record, I think WCF is powerful, but our organization has grown tired of how complicated it can be to turn all the knobs and hit all the switches to get it working right, and set up easily from one install to the other. 为了记录,我认为WCF功能强大,但我们的组织已经厌倦了转动所有旋钮并点击所有开关以使其正常工作并从一个安装轻松设置到另一个安装的复杂程度。 MVC, on the other hand, just works... and since we already use it to service our HTML views, it's a real joy to only have to add a little extra code to have it handle service calls, too.
另一方面,MVC正常工作......由于我们已经使用它来为我们的HTML视图提供服务,所以只需要添加一些额外的代码来处理服务调用也是一件非常愉快的事情。 Just a personal preference, of course.
当然只是个人偏好。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.