简体   繁体   English

asp.net webapi vs asp.net mvc restlike操作

[英]asp.net webapi vs asp.net mvc restlike actions

I've been taking a look at the asp.net webapi stuff and I'm curious to know what the tipping point is for using it over using a normal mvc controller that supports rest like urls. 我一直在看asp.net webapi的东西,我很好奇知道与使用支持url之类的常规mvc控制器相比使用它的引爆点是什么。

I've done a bit of a search and can't find any articles that specifically talk about when is the most appropriate time to use each. 我做了一些搜索,找不到任何专门讨论何时使用它们的最合适的文章。

The separation is now: 现在,分隔为:

If you need to spit out dynamic views (ie view gets rendered on the server typically using Razor) then use ASP.NET MVC. 如果您需要吐出动态视图 (即通常使用Razor在服务器上渲染视图),则可以使用ASP.NET MVC。 Historically you could provide data but Web API is richer (it supports content negotiation). 从历史上讲,您可以提供数据,但是Web API更丰富(它支持内容协商)。

If you need to provide data , then use ASP.NET Web API. 如果需要提供数据 ,请使用ASP.NET Web API。 You could fit in the view support but it is not meant for it. 您可以加入视图支持,但这并不意味着它。


I can see these will be joined together as ASP.NET web stack in the future versions (not the upcoming release). 我可以看到它们将在将来的版本(而不是即将发布的版本)中作为ASP.NET Web堆栈结合在一起。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM