2012-09-04 51 views
1

我正在阅读以下“WebAPI是一个伟大的建设HTTP服务”,所以我想更多地了解这个现在我正在改变到MVC4。WebAPI vs MVC 4控制器为jquery调用我的方法,返回json

我的web应用程序使用jQuery来调用我的控制器上返回json结果的方法。这是否意味着将来使用WebAPI控制器会更好?

对传统控制器进行的调用与对WebAPI控制器的调用之间的高速缓存是否有区别?

回答

3

My web application uses jQuery to make calls to methods on my controller that return json results. Does this mean it would be better for me in future to use the WebAPI controllers?

不一定,你可以返回JSON出与MVC为好。 Web.API为您提供许多开箱即用的特性,您必须使用MVC自行实现它。

Is there any difference in caching between a call made to a traditional controller and a call made to a WebAPI controller?

缓存是一个很宽泛的概念。你可以使用OutputCaching和MVC,你也可以采用输出缓存到web.api。看看here

不过,也有除了OutputCaching各种缓存技术,比如拥有自己的高速缓存和管理您的缓存容器等

对于我来说,web.api可用于单页的应用程序,数据层或服务层。