Link to home
Start Free TrialLog in
Avatar of Jorge Maldonado
Jorge Maldonado

asked on

MVC Controllers or WEB API

I am developing an information system for the World Wide Web using ASP.NET Core 3.1 (MVC of course) and we are considering to port it to mobile Android and iOS devices in the future.
Currently, I am using the "normal" controller actions to perform DB operations and everything is going on well.
However, it seems to me that, when starting to develop the mobile apps, I will have to "re-write" the controller's actions and make them WEB API's (RESTful services for example).
As a WEB API newbie, Is my panorama correct? Should I consider to use WEB API's instead of integrating everything within my MVC project?

Respectfully,
Jorge Maldonado
SOLUTION
Avatar of Chinmay Patel
Chinmay Patel
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Jorge:
Mobile solution does not mean you shall use Web API. It is actually a front end requirement that will mostly be handled by your HTML/CSS constructs in your pages.
Your decision should be based on project size and complexity as well whether there is a requirement to provide an API for third party integration, for small project your default choice is MVC for faster development, see link below for comparison:
https://www.gangboard.com/blog/mvc-vs-web-api

AT the end it all depends how you build it and what your future needs are. Web API is good for clear separation between front and back end but it is  more work and costly to develop than MVC.
Saludos,
Miguel
Avatar of Jorge Maldonado
Jorge Maldonado

ASKER

Hello,

From the answer provided by Miguel Oz, I have a question.

Let´s say that I finish my web application with ASP.NET Core MVC and all of the interactions with the database are included in a class library that contain CRUD operations. Such class library is referenced in my MVC project so it is possible to call the services to insert, update, delete and read records. So far, so good.

Now, I start developing a mobile application with Xamarin that will get data from the same database. This mobile app will be compiled to run on iOS and Android platforms. What I see is that I cannot use (reference) the same class library developed for the ASP.NET Core MVC project above.
Is this correct? Or maybe my understanding is wrong.
If this is correct then it is necessary to consider another way to interact with the database from the mobile app and I think that WEB APIs are a choice.

I will very much appreciate your feedback.

Respectfully,
Jorge Maldonado
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial