asp.net-mvc 带有 ASP.NET MVC 的 RESTful Web 服务

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/220845/
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 22:48:44  来源:igfitidea点击:

RESTful Web Services with ASP.NET MVC

asp.net-mvcrest

提问by Shiju

Do you think ASP.NET MVC is able to develop RESTful web services and which approach you would use for it?

您认为 ASP.NET MVC 是否能够开发 RESTful Web 服务以及您将使用哪种方法?

回答by Shiju

I have written a whole series of posts on developing a RESTful Web Service using ASP.Net MVC... well at least I'm 80% of the way through after 8 posts. Have a look at:

我已经写了一系列关于使用 ASP.Net MVC开发 RESTful Web 服务的帖子......至少在 8 个帖子后我已经完成了 80%。看一下:

http://shouldersofgiants.co.uk/blog/

http://shouldersofgiants.co.uk/blog/

The web service I'm developing supports multiple representations (XHTML / JSON / XML / HELP) handles as many possible errors as I could find and supports POST overloading.

我正在开发的 Web 服务支持多种表示(XHTML / JSON / XML / HELP),可以处理尽可能多的可能错误,并支持 POST 重载。

回答by SaaS Developer

Generally, I would say yes it is possible for ASP.Net MVC to develop RESTful web services. However, many times the consumers of the data are unique enough where this may not be the best approach.

一般来说,我会说是的,ASP.Net MVC 可以开发 RESTful Web 服务。然而,很多时候数据的消费者足够独特,这可能不是最好的方法。

For larger application services or more complex services, I would recommend developing your MVC Controllers in a RESTful manner to be consumed by the views as MVC is designed. I would then think about ADO.Net Data Services or WCF for large scale data services.

对于更大的应用程序服务或更复杂的服务,我建议以 RESTful 方式开发您的 MVC 控制器,以便在设计 MVC 时由视图使用。然后我会考虑用于大规模数据服务的 ADO.Net 数据服务或 WCF。

回答by Mukus

As of MVC 4 Web API officially supports building RESTful web services.

从 MVC 4 Web API 开始正式支持构建 RESTful Web 服务。

回答by CraftyFella

Peter,

彼得,

In response to calebjenkins, ADO.Net data services is really nice if you want to create a restful version of your database.

作为对 calebjenkins 的回应,如果您想创建数据库的宁静版本,ADO.Net 数据服务非常好。

If you want more control over your restful webservice then i would use WCF web services. Or if your datastore isn't a database, then ADO.NET data service isn't really the right solution. Here is a really nice articlewhich got me started.

如果你想更多地控制你的宁静网络服务,那么我会使用 WCF 网络服务。或者,如果您的数据存储不是数据库,那么 ADO.NET 数据服务并不是真正正确的解决方案。这是一篇非常好的文章,它让我开始了。

回答by calebjenkins

I would seriously look at ADO.NET Dataservices. (formaly code named Astoria) There's some really nice tooling for Restful services in there!

我会认真研究 ADO.NET Dataservices。(正式代码名为 Astoria)那里有一些非常好的 Restful 服务工具!

http://msdn.microsoft.com/en-us/data/bb931106.aspx

http://msdn.microsoft.com/en-us/data/bb931106.aspx