What is the difference between MVC Controller and Web API Controller in ASP.NET MVC 6?

后端 未结 2 555
独厮守ぢ
独厮守ぢ 2020-12-14 00:59

In ASP.NET 5 MVC 6 Microsoft merged the normal MVC controller class (Controller) with the Web Api controller class (ApiController). Now there is ju

2条回答
  •  轮回少年
    2020-12-14 01:36

    I think you're thinking into this too much.

    Your first question "What is the difference of MVC Controller and Web API Controller in ASP.NET MVC 6?" presupposes that they are different, but they are not. They are merged, so there is no difference.

    If you want to define separate routes to cordon off your action methods that don't return View results, then go for it. It's up to you how to organize your application. Asking "Which way is now the preferred one to create web apps?" is pointless, since that's up to you to decide for your application, and there's not going to be a more common way of doing things until after MVC 6 has been in production use for a good length of time.

提交回复
热议问题