Base solution for your next web application
Open Closed

Distributed WebAPI and MVC Site #739


User avatar
0
roy created

Hi,

With ABP, if I want to publish my Web API on one server and MVC Site on another server, how should I organize the assembly and dependency. (when the mvc site get an ajax call , it just simply dispatch the request to the Web API Server with HttpClient )

PS. the requirement is coming from : the Web API not just supply service to MVC Site , but also other app in different platform(like mobile app, desktop app, etc.)


3 Answer(s)
  • User Avatar
    0
    hikalkan created
    Support Team

    You can host web api in a seperated empty web application (like this project: <a class="postlink" href="https://github.com/aspnetboilerplate/sample-odata/tree/master/src/AbpODataDemo.WebHost">https://github.com/aspnetboilerplate/sa ... mo.WebHost</a>). Then you can call WebAPI from your MVC application as you normally do. For example: <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate-samples/blob/master/ConsoleRemoteWebApiCall/CallApiFromConsole/Program.cs">https://github.com/aspnetboilerplate/as ... Program.cs</a>

    So, you will have two application actually (one consists of core, application and web api layers and a web host project. Other one includes just an MVC project.)

  • User Avatar
    0
    roy created

    Yes, this solution work fine , but some great features of ABP ( like dynamic Web API , dynamic service proxy script according to IXxxAppService ) seems unavailable, right?

  • User Avatar
    0
    paddyfink created

    Hello,

    Like you I created also a separate web api project to host it on its own server. You can still have all the features abp.

    for the Dynamic web api, you just have to add this code on your module class ( you have to create manually one and inherited from abpmodule) :

    DynamicApiControllerBuilder
                   .ForAll<IApplicationService>(typeof(MyAppApplicationModule).Assembly, "app")
                   .WithConventionalVerbs()
                   .Build();