3

I am developing a new large Web Application using ASP.NET Web API. In that, I want to separate all controller classes into one different class library from ASP.NET MVC project.. Please consider following options.

Case 1 : Keeping controllers in same ASP.NET MVC project

Case 2 : Separating controllers in separate class library

  1. Is it right to go with Case#1 as I think this controller can be reusable by other projects or hosting in windows service instead of IIS Web Application.

  2. Also if in future if I want to access Web-API methods from Android,IPhone native apps then does it works for me in both cases Case#1 and Case#2

  3. Is there any performance issue with Case#2.

  4. What would be the best practice to register multiple controllers in both cases using UnityContainer.RegisterType ?

Community
  • 1
  • 1
mit
  • 1,763
  • 4
  • 16
  • 27

1 Answers1

4

Putting your Web API code in a different project than your MVC code should be a best practice. There is no reason not to do it.

Darrel Miller
  • 139,164
  • 32
  • 194
  • 243