MVC and WebMAP
by John Browne, on Aug 22, 2017 11:05:24 AM
Being an introduction into how WebMAP implements ASP.NET MVC in generated code.
WebMAP takes a C# desktop app and converts it to a web app. The fundamental internal architecture is loosely based on ASP.NET MVC or Web API, depending on how you want to look at it.
First, a little background.
Unlike a desktop app, a web app has to have a front end and a back end. The back end is the code that runs on the web server and the front end is everything that happens in the browser.
Unlike a "traditional" ASP.NET MVC 4 application, WebMAP creates a single page application on the client side that uses JSON--rather than views--to dynamically update each page based on event handlers. This is how it resembles Web API in that it's sending JSON rather than views.
Server side code
MVC (model vie controller) is a pattern that aims to implement the design principle of separation of concerns. Here's how WebMAP uses MVC:
- Models hold data to build the view. The model contains a Build() method used to actually construct the view.
- Views are the user presentation. WebMAP views consist of pairs of files for each form in the client application: one HTML file and one CSS file. These files render and style all the objects on the client-side forms.
- Controllers are like traffic cops--the controller takes an incoming HTTP request and routes it to the appropriate logic file.
- Logic files are where the original business code resides. Logic files are the part of the application that implements business rules, interacts with the data layer, validates input, and so on. Llogic files update the models with new data, which in turn then update the view.
Client side code
The client framework receives model updates via JSON objects from the server and updates the view dynamically. Views are nothing more than what the user sees in the browser, including all the controls and data.
How JSON is used
Watch it on TV
This is all explained in a lot more detail in a video I just put up on YouTube. Please take a look and post your questions and comments here.