WCF REST Web API and MVC on the same server and port

微信扫一扫,分享到朋友圈

WCF REST Web API and MVC on the same server and port

I’m looking at putting together a REST based system which still has a standard browser style access. My desire is to have both of these on the same machine, but what are my options?

  • Use IIS to host both the web-site and the REST service (different URIs, e.g. http://mysite.com/
    and http://mysite.com/api
  • Use IIS and some magic I don’t yet know to have two domains mapped to the same machine but different services (e.g. http://www.mysite.com
    and http://api.mysite.com
  • Combine the two technologies into a single service (that perhaps uses routing tables to direct the requests to MVC or WCF where appropriate).

My preference would be the third option, this would allow me to have a single code-base and single repository accessing. The WCF page on codeplex
mentions in its release notes, “not tested with MVC3” – is this suggesting that this is a possible approach?

I’m not keen on using MVC for the REST implementation as it is intended that the majority of interaction with my site goes via API, so I want that as the focus.

I’ve ported the contact manager to use MVC 3. It definiately works though we’ve not done exhaustive testing. The one thing in general to cognizant of with regards to web api is that both MVC Routes and Service Route are greedy. If your default route is first then MVC will try to grab your HTTP Service requests. One thing you will want to do is put your Service Route first before your MVC routes. If you run into additional issues, you may need to use custom routing constraints.

微信扫一扫,分享到朋友圈

WCF REST Web API and MVC on the same server and port

A heartily welcome for Zope in the Python 3 wonderland

上一篇

SQL Allow One Return Value for Field

下一篇

你也可能喜欢

WCF REST Web API and MVC on the same server and port

长按储存图像,分享给朋友