Question

I am designing architecture of my Project, which would have

  1. Web Application (Client)
  2. Windows Application (Client)
  3. Mobile Application (Client)

  4. Service Layer (would be done using Web Api)

  5. Business Logic Layer
  6. Data Access Layer
  7. Data Object Layer

My question is do i need to create two different MVC projects for Web Application and Service Layer (Web Api). As both for them would be hosted. I have seen that WebApi template also supports ActionMethods (when class is inherited by Controller class). So can Web Api template be used as WebApp as well as Service Layer.

What is the best practice that is followed.

I know there similar questions on these locations

What is the correct architecture for MVC4 WebAPI

Using ASP.NET WebApi with a 3 Tier Architecture

But i wanted to be specific with my requirement.

Thanks in advance.

Was it helpful?

Solution 2

The only practical difference I can see is that if you put them in the same project, your API is suddenly tightly coupled to your web app and can never live without it, which is unnecessary.

Create separate projects in the same solution and host them as two separate sites.

OTHER TIPS

Defining the architecture requires establishing responsibility of each component. ASP.NET Web API must usually be a light layer concerned with the presentation of the state in pure HTTP semantics - kinda similar to what SOAP does in a traditional web service.

As such, in an ASP.NET Web API application you should have really very little business logic. So I would not simply add overhead of an additional physical layer which includes network latency, serialization and deserialization, etc.

This is my preferred approach:

enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top