Using .NET MVC as front-end and Web API as back-end
A simple approach to develop modular web apps without leaving Visual Studio.
I have been developing web applications for 5+ years and have worked on multiple technologies to build front-end including ASP.NET WebForms, MVC, Angular & jQuery (not to forget HTML, CSS & JavaScript).
When I first got introduced to Angular, I liked it very much as it enabled true separation of UI and business logic. I built the front-end in Visual Studio Code using Angular and back-end using Web API in Visual Studio. The only pain-point was to work with two separate IDEs. I know that in an ideal scenario these two are jobs for separate people, but for smaller projects (and limited people in my workforce), I prefer to get this done single-handed. I tried to explore possibility of using Angular inside Visual Studio but that required too much config and still did not seem to have full support (this may have changed now).
Recently I got my hands on another small project and I started exploring my options to do all development inside one IDE. Since my preferred technology for back-end was still Web API (with EF & SQL), I had to find a solution that worked inside Visual Studio.
ASP.NET MVC offered a good choice for building extension-less URLs and handles routing very well at server side, I decided to build a setup where MVC will only act as a front-end UI + routing tool and all back-end stays with Web API. Thus, I built all the Views and Layouts using MVC without any business logic inside MVC Controllers. All MVC controllers only had one line of code:
return View();
For requesting/posting data to/from server, I used good old friend jQuery (still the 2nd highest downloaded front-end framework (after React.js).
Thus, my setup was as follows:
User Interface: MVC Controllers and Views returning plain HTML an no server-side code (except page title using ViewBag.Title)
User Interaction: jQuery with Ajax
Back-End: Web API using Models, Controllers & Entity Framework to connect to database and returning pure JSON.
So far, this approach looks like the simplest implementation for building truly modular applications and without learning additional frameworks. As a matter of fact, I am also building a Mobile application that will utilize existing Web API end-points to fetch/save data and I hardly need to do any additional development at the back-end.
Do let me know your views so that I can learn more.