I have this doubt, because always when I create a Web API project I use the API controllers to get data and I create a normal controller where I define all my methods that returns ActionResult to redirect to the views and I am not sure if this is the best way.
What is the correct way to do this?
Web API is not for views. API stands for application programming interface - that is, there is no user interface (views) that a user can interact with.
There is another framework with view functionality built-in: ASP.NET MVC . It will even run side-by-side within your Web API project - see How to add MVC to existing web API project .
So in short:
System.Web.Mvc.Controller
) System.Web.Http.ApiController
) when you want to return data to an application or browser.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.