2

I've just started the project and I have this sort of parts in my solution

  • MyApp.Web MVC Web Application
  • MyApp.Data Class Library
  • MyApp.Domain Class Library
  • MyApp.Service Class Library
  • MyApp.Utility Class Library

So I wanted to have webapi in my application, and my question is where should I put the webapi codes. in separate part like MyApp.API or in Data or Service part.

thank you.

2
  • Isn't Web API a separate project? – Robert Harvey Jul 31 '15 at 14:55
  • no , not yet . my primary question is actually THAT . should i put webapi in a separate project or inside the Data layer – M.R.Safari Jul 31 '15 at 15:23
1

I prefer this structure:

  1. MyApp.Web // UI
  2. MyApp.Core // Context
  3. MyApp.Domain
  4. MyApp.Service
  5. MyApp.Api // WebAPI
  6. MyApp.Utility // it's depended on your case !, I didn't use this layer so far.

If you use DI in your project, you should use Custom Controller Factory, so I prefer WebAPI as separated layer and create specific Custom Controller Factory, instead of something global that covering MVC Controller too.

1

You should absolute not put it in the data layer. That would be weird because none of the dependencies you need for web api are, and should not be, present in the data layer.

It is fairly common to have mixed mvc and web api into the same assembly and it has the advantage that deployment is easier.

If you want a more clean approach. Clean in the sense that we keep the number of unrelated dependencies to a minimum in each project, you can introduce a seperate assembly with web api only. This will sligtly minimize the risk of running into dll hell but complicate deployment slightly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.