We have a solution with this structure.
We want to use a dns structured like this:
http://www.ourapp.com points to OurApp.Web
http://api.ourapp.com points to OurApp.Api
We want to host on AppHarbor.
How can we do this?
WCF offers request-reply, one-way, or duplex while Web API is by default request-reply only. WCF is used for developing SOAP-based services whereas Web API is used for both SOAP-based and RESTful services. WCF does not offer any support for MVC features whereas Web API supports MVC features.
Since WCF service application and MVC application both are in the same solution, we have to build the Service first and then the MVC application in order to consume the service in MVC application. Do the following for that, Right Click on the MvcWcfEF Solution in Solution Explorer and click on properties.
Right Click on the MvcWcfEF Solution in Solution Explorer and click on properties. Check the "Multiple Startup Project " and set the application priority for WCF and MVC application (WCF service should be first and MVC afterwards), as in the following image.
Step 1) Open Visual Studio and Create a web project. Step 2) Name your project and select MVC template. Step 3) A default Scaffold template generates for MVC having HomeController. Step 4) Same steps apply to Web API application as well, just select Empty project.
AppHarbor currently only supports deploying one application from any given repository. One option might be to fold the API into the web project. I did this for a non-web API WCF service here.
Another option is to maintain two AppHarbor applications, and use solution files named according to what application you want deployed for that application. That is, OurApp.Web.sln
contains the Web project and any supporting projects and, OurApp.Api.sln
references the API project and any supporting projects. Read more about AppHarbor solution file convention.
(disclaimer, I'm co-founder of AppHarbor)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With