开发者

Would it be better to use Asp.net mvc or web services?

I have asp.net mvc app written a couple of years ago and the more I add to it, I tend to make REST/AJAX calls to the controller to get data from it.

My question is do I ca开发者_运维知识库rry on working in this way or should I expose the data as a separate REST services (WCF way of doing things)?

It feels that the boundary on what a mvc app is designed to do and the design of web service is getting blurred. The Mvc app (apart from separation) initially produced web pages, now it is being used to provide service based data.

JD


I see two possible scenarios

Single web app. In this case you carry on adding methods to the controller. This is good because it keeps relevant to the controller functionality in one place and will save you time. It is not suitable if the controller is being called from another web application. Simple, ugly but works, takes little time for development and much time for maintenance.

Web app + web service. You can segregate data retrieval methods into the service interface. The positive side is that you system becomes much more modular and independent, which is good for maintenance. If you predict that there will be other methods that will be added soon or if the methods are used by other web applications, then this path is probably better than extending the current web app. The negative side is that the new service will require some refactoring to the current web application and will take time to be developed/tested etc. This decision brings more complexity, but makes your application easy to be extended.


I think WCF has several advantages over MVC if you are strictly sending data, specifically in terms of data formats being unambiguous (SOAP vs. using home-brewed encodings), industry-wide tool support, excellent support for different types of bindings (i.e. not just HTTP), various transport level services, nice logging and tracing capabilities, etc.

In the end though, it boils down to: is there a significant enough advantage to going with WCF for your case. That is something that you'd have to figure out yourself.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜