MVC & Web Api projects within same Solution

后端 未结 3 606
余生分开走
余生分开走 2021-02-02 11:28

I have an MVC 4 project sitting atop an N-tier application. I now have a requirement to to be able to consume the application programmatically. I have created a new Web API proj

3条回答
  •  盖世英雄少女心
    2021-02-02 11:53

    WebApi is an alternative Service oriented application from Microsoft just like WCF. But WCF uses SOAP protocol and WebAPI uses HTTP protocol for communication.

    So if you are using WCF to provide service for your MVC application you would host that wcf service seperately and consume its service by MVC application, EXACTLY same way you have to host your WebAPI project seperately and provide service to your Web application (MVC).

    for some reasons if you want them (MVC and WebAPI) to use in the same project, follow this rules from this article.

    http://odetocode.com/blogs/scott/archive/2013/07/01/on-the-coexistence-of-asp-net-mvc-and-webapi.aspx

提交回复
热议问题