在.NET中实现基于REST的Web服务的最佳方法是什么?

时间:2022-10-22 09:06:35

So far my options are ADO.Net data services, WCF REST Starter Kit(not sure if I can use it, as their EULA is hard to comprehend and confusing), ASP.NET MVC.

到目前为止,我的选择是ADO.Net数据服务,WCF REST入门套件(不确定我是否可以使用它,因为它们的EULA难以理解和混淆),ASP.NET MVC。

There are quite a few posts, but I want to see if there are anymore frameworks that I am missing. Also please post your experiences if you already used any of the above options.

有很多帖子,但我想看看是否还有我缺少的框架。如果您已使用上述任何选项,请发布您的经验。

The scenario I am looking to use is for saving and retreiving some data from a SQL Server database. I am looking for something that already had some infrastructure built into it. I read the other questions but I did not get any concrete experiences that people had with the above mentioned options, so wondering if things changed over time.

我想要使​​用的方案是从SQL Server数据库保存和检索一些数据。我正在寻找已经内置了一些基础设施的东西。我读了其他问题,但我没有得到人们对上述选项的任何具体经验,所以想知道事情是否会随着时间而改变。

Thanks in advance.

提前致谢。

Clarification # 1: I am currently limiting my options to MS Stack

澄清#1:我目前正在限制我对MS Stack的选择

5 个解决方案

#1


Actually I think that ADO.NET for Data Services (previously called Astoria) is what you want.

实际上我认为ADO.NET for Data Services(以前称为Astoria)就是你想要的。

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

#2


WCF is certainly not the way to go as far as v1 is concerned. It prevents you from implementing many of the constraints of ReST architectures.

就v1而言,WCF肯定不是最佳选择。它可以防止您实现ReST体系结构的许多约束。

If you want to do ReST over http, why not give a look at OpenRasta, that has been built from the ground-up to support REST scenarios:

如果你想通过http进行ReST,为什么不看看OpenRasta,它是从头开始构建的,以支持REST场景:

http://trac.caffeine-it.com/openrasta

Seb

#3


If you are using .asmx wed services you can tag the class with ScriptService and then request Json in the AJAX call to get Json back.

如果您使用的是.asmx wed服务,则可以使用ScriptService标记该类,然后在AJAX调用中请求Json以使Json返回。

#4


If you website is already running MVC and it's just easier add an extra view and dump xml/json instead of HTML content. (Stack Overflow does this for their RSS feeds)

如果您的网站已经在运行MVC,那么只需添加一个额外的视图并转储xml / json而不是HTML内容。 (Stack Overflow为他们的RSS提要执行此操作)

If your wanting to add custom headers like Basic Http Authentication, X-HTTP-Method-Override for support for put/delete (as browsers pipeline only supports get/post), its easy to do in the Rest Starter Kit, and almost impossible to do currently in WCF 3.5 (possible with asp.net modules with attributes set allowing httpcontext)

如果您想添加自定义标头,例如Basic Http Authentication,X-HTTP-Method-Override以支持put / delete(因为浏览器管道只支持get / post),它很容易在Rest Starter Kit中完成,而且几乎不可能目前在WCF 3.5(可能与asp.net模块,属性设置允许httpcontext)

Rest Starter Kit fills in all the gaps that WCF 3.5 left out!

Rest Starter Kit填补了WCF 3.5遗漏的所有空白!

The REST Starter Kit has a ASP.NET Pre-Release Components, as in "The software is licensed "as-is." You bear the risk of using it. It may never get released as a stable release " View Licence

REST入门套件具有ASP.NET预发布组件,如“软件已获得许可”一样。“您承担使用它的风险。它可能永远不会作为稳定版本发布”查看许可证

To get you started PluralSight have some awesome video tutorials about REST and the REST Starter Kit.

为了帮助您入门,PluralSight提供了一些关于REST和REST入门套件的精彩视频教程。

#5


ASP.NET MVC isn't really like the other things. It is a web development model, an alternative to WebForms.

ASP.NET MVC并不像其他东西那样。它是一个Web开发模型,是WebForms的替代品。

As to implementing a REST based Web Service, WCF is probably the way to go. Its is pretty much a matter of setting a few extra attributes, configuring a single xml file and thats about it. So far as infrastructure goes, WCF is about as complete as any choices out there, as it has bandwidth and concurrency built in and should you decide to switch transports ( to say, named pipes or TCP ) or wish to switch to using SOAP instead, its a trivial switch. Additionally, tracing is built in, which can be handy when things go wrong.

至于实现基于REST的Web服务,WCF可能是最佳选择。它几乎是设置一些额外的属性,配置单个xml文件及其相关问题。就基础设施而言,WCF与任何选择一样完整,因为它具有内置的带宽和并发性,你应该决定切换传输(比如命名管道或TCP),或者希望切换到使用SOAP,它是一个微不足道的开关。此外,内置跟踪功能,在出现问题时可以很方便。

One final option might be Web Methods. If you are just trying to Ajax enable a website, Web Methods would probably do the trick.

最后一个选项可能是Web方法。如果您只是尝试使用Ajax启用网站,Web方法可能会成功。

As to if you are missing any frameworks... if you are dealing with MS dev stack, no, thats pretty much it, except perhaps classic web services which are still supported.

至于你是否缺少任何框架......如果你正在处理MS dev堆栈,不,这几乎就是它,除了可能仍然支持的经典Web服务。

If you are talking non-MS languages, there are half a hundred different web service standards for all the various languages ( Java, Python, Ruby, etc... ). If you aren't confined to MS technologies, you should make that clear as it opens up the options a ton.

如果您正在谈论非MS语言,那么所有各种语言(Java,Python,Ruby等)都有不同的Web服务标准。如果您不局限于MS技术,那么您应该明确这一点,因为它打开了大量的选项。

EDIT: That is not to say you can't do REST based viewless interfaces with ASP.NET MVC. If just means you have zero built in infrastructure and will basically be rolling your own. Thus, no load handling, no DDOS protection, no fault tolerance, etc...

编辑:这并不是说你不能用ASP.NET MVC做基于REST的无视界面。如果只是意味着你没有内置的基础设施,并且基本上将自己滚动。因此,无负载处理,无DDOS保护,无容错等...

#1


Actually I think that ADO.NET for Data Services (previously called Astoria) is what you want.

实际上我认为ADO.NET for Data Services(以前称为Astoria)就是你想要的。

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

#2


WCF is certainly not the way to go as far as v1 is concerned. It prevents you from implementing many of the constraints of ReST architectures.

就v1而言,WCF肯定不是最佳选择。它可以防止您实现ReST体系结构的许多约束。

If you want to do ReST over http, why not give a look at OpenRasta, that has been built from the ground-up to support REST scenarios:

如果你想通过http进行ReST,为什么不看看OpenRasta,它是从头开始构建的,以支持REST场景:

http://trac.caffeine-it.com/openrasta

Seb

#3


If you are using .asmx wed services you can tag the class with ScriptService and then request Json in the AJAX call to get Json back.

如果您使用的是.asmx wed服务,则可以使用ScriptService标记该类,然后在AJAX调用中请求Json以使Json返回。

#4


If you website is already running MVC and it's just easier add an extra view and dump xml/json instead of HTML content. (Stack Overflow does this for their RSS feeds)

如果您的网站已经在运行MVC,那么只需添加一个额外的视图并转储xml / json而不是HTML内容。 (Stack Overflow为他们的RSS提要执行此操作)

If your wanting to add custom headers like Basic Http Authentication, X-HTTP-Method-Override for support for put/delete (as browsers pipeline only supports get/post), its easy to do in the Rest Starter Kit, and almost impossible to do currently in WCF 3.5 (possible with asp.net modules with attributes set allowing httpcontext)

如果您想添加自定义标头,例如Basic Http Authentication,X-HTTP-Method-Override以支持put / delete(因为浏览器管道只支持get / post),它很容易在Rest Starter Kit中完成,而且几乎不可能目前在WCF 3.5(可能与asp.net模块,属性设置允许httpcontext)

Rest Starter Kit fills in all the gaps that WCF 3.5 left out!

Rest Starter Kit填补了WCF 3.5遗漏的所有空白!

The REST Starter Kit has a ASP.NET Pre-Release Components, as in "The software is licensed "as-is." You bear the risk of using it. It may never get released as a stable release " View Licence

REST入门套件具有ASP.NET预发布组件,如“软件已获得许可”一样。“您承担使用它的风险。它可能永远不会作为稳定版本发布”查看许可证

To get you started PluralSight have some awesome video tutorials about REST and the REST Starter Kit.

为了帮助您入门,PluralSight提供了一些关于REST和REST入门套件的精彩视频教程。

#5


ASP.NET MVC isn't really like the other things. It is a web development model, an alternative to WebForms.

ASP.NET MVC并不像其他东西那样。它是一个Web开发模型,是WebForms的替代品。

As to implementing a REST based Web Service, WCF is probably the way to go. Its is pretty much a matter of setting a few extra attributes, configuring a single xml file and thats about it. So far as infrastructure goes, WCF is about as complete as any choices out there, as it has bandwidth and concurrency built in and should you decide to switch transports ( to say, named pipes or TCP ) or wish to switch to using SOAP instead, its a trivial switch. Additionally, tracing is built in, which can be handy when things go wrong.

至于实现基于REST的Web服务,WCF可能是最佳选择。它几乎是设置一些额外的属性,配置单个xml文件及其相关问题。就基础设施而言,WCF与任何选择一样完整,因为它具有内置的带宽和并发性,你应该决定切换传输(比如命名管道或TCP),或者希望切换到使用SOAP,它是一个微不足道的开关。此外,内置跟踪功能,在出现问题时可以很方便。

One final option might be Web Methods. If you are just trying to Ajax enable a website, Web Methods would probably do the trick.

最后一个选项可能是Web方法。如果您只是尝试使用Ajax启用网站,Web方法可能会成功。

As to if you are missing any frameworks... if you are dealing with MS dev stack, no, thats pretty much it, except perhaps classic web services which are still supported.

至于你是否缺少任何框架......如果你正在处理MS dev堆栈,不,这几乎就是它,除了可能仍然支持的经典Web服务。

If you are talking non-MS languages, there are half a hundred different web service standards for all the various languages ( Java, Python, Ruby, etc... ). If you aren't confined to MS technologies, you should make that clear as it opens up the options a ton.

如果您正在谈论非MS语言,那么所有各种语言(Java,Python,Ruby等)都有不同的Web服务标准。如果您不局限于MS技术,那么您应该明确这一点,因为它打开了大量的选项。

EDIT: That is not to say you can't do REST based viewless interfaces with ASP.NET MVC. If just means you have zero built in infrastructure and will basically be rolling your own. Thus, no load handling, no DDOS protection, no fault tolerance, etc...

编辑:这并不是说你不能用ASP.NET MVC做基于REST的无视界面。如果只是意味着你没有内置的基础设施,并且基本上将自己滚动。因此,无负载处理,无DDOS保护,无容错等...