Web服务或Windows应用程序连接到MVC 4个Web API? [英] Web Service or web API for connecting a windows application to MVC 4?

查看:226
本文介绍了Web服务或Windows应用程序连接到MVC 4个Web API?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

搜索整个一天约我应该用什么之后,我不知道什么样的选择将是最适合我的需要,所以我希望更有经验的人可以帮助我。

After searching the entire day about what I should use, I'm not sure what option would be best for my needs so I hope someone with more experience could help me out.

我有一个的WinForms 应用程序( C#)和 ASP.NET MVC 4 Web应用程序( C#)。
我希望连接这些,我们的目标是从我在 MVC 4 项目使用的数据库发送和接收的数据,但是从窗内窗体应用程序。我从窗户发送的数据形成应用到数据库中,然后由 MVC 4 Web应用程序使用。

I have a winforms application (c#) and a ASP.NET MVC 4 web application (c#). I wish to connect these, the goal is to send and receive data from the database which I use in the MVC 4 project, but from within the windows forms application. The data I send from the windows forms application to the database, is then used by the MVC 4 web application.

我是全新的Web服务/ 网​​页API 的,所以我真的不能决定什么办法是最好的。任何帮助将是非常美联社preciated ..

I am entirely new to web services / Web Api's so I can't really decide what option would be best. Any help would be much appreciated..

推荐答案

如果您已经创建 MVC4 的项目,那么你可以添加动作任何控制器
并返回 JSON 象下面这样的数据:

If you already created MVC4 project then you can add actions to any controller and return JSON data like below :

public JsonResult GetCategoryList()
{
    var list = //return list
    return Json(list, JsonRequestBehavior.AllowGet);
}

也可以创建的 MVC4 新项目,选择的WebAPI 模板。这将创建的WebAPI项目为你。它将会例子。所以它会容易为创建的WebAPI 。在的WebAPI 它返回的数据自动转换为 XML JSON 要求

or you can create new project of MVC4 and select WEBAPI template . It will create webapi project for you .It will create with example .so it will easy for to create webapi.In webapi it return data automatically convert to xml and json as per request

WCF 的Web API抽象映射到 ASP.NET 的Web API 大致如下:

The WCF Web API abstractions map to ASP.NET Web API roughly as follows

WCF Web AP -> ASP.NET Web API
Service -> Web API controller
Operation -> Action
Service contract -> Not applicable
Endpoint -> Not applicable
URI templates -> ASP.NET Routing
Message handlers -> Same
Formatters -> Same
Operation handlers -> Filters, model binders

<一个href=\"http://wcf.$c$cplex.com/wikipage?title=How%20to%20Migrate%20from%20WCF%20Web%20API%20to%20ASP.NET%20Web%20API\"相对=nofollow>其他链接

这篇关于Web服务或Windows应用程序连接到MVC 4个Web API?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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