MVC and Web API Projects in the same Solution

后端 未结 2 1834
忘了有多久
忘了有多久 2021-02-04 17:58

I created a solution a while ago that contains a Web API 2 project (provides JSON data to mobile devices) and a Class Library (includes my data access services).

The Web

2条回答
  •  耶瑟儿~
    2021-02-04 18:48

    What I like to do, is to have the MVC and WebAPI project in two separate projects (separation of concerns) but let them share the same business logic.

    I like to utilize the Command and Query pattern. So all commands and queries is located in another solution project, which both the MVC and WebAPI project has access to.

    I deploy the MVC project on the www.domain.com path, the WebAPI project on the api.domain.com and enable CORS on WebAPI for the www origin.

提交回复
热议问题