Introduction to Mvc
-
Upload
claudiu-socaci -
Category
Education
-
view
131 -
download
3
description
Transcript of Introduction to Mvc
04/13/2023Infobest Romania
MVCPart 1
04/13/2023Infobest Romania
MVC Architecture M, V and C Separation of Concerns .NET MVC Framework Demo
Topics
Create a project.How is it configured by default? Model, View Controller Razor Routing Friendly URLs Test driven dev Bundling Minification Validation Forms Send data to controller from view Form security
04/13/2023Infobest Romania
MVC Architecture
04/13/2023Infobest Romania
Players
Controller: - Handles a request from a View and updates the Model that results in a change of the Model's state.
- Sends Data to View
Model: The business entity on which the overall application operates. Many applications use a persistent storage mechanism (such as a database) to store data. MVC does not specifically mention the data access layer because it is understood to be encapsulated by the Model.
View: The user interface that renders the Model into a form of interaction.
MVC Architecture
04/13/2023Infobest Romania
To implement MVC in .NET we need mainly three classes (View, Controller and the
Model).
MVC Architecture
04/13/2023Infobest Romania
The process of breaking a computer program into distinct features that overlap in functionality as little as possible
MVC design pattern aims to separate content from presentation and data-processing from content. Theoretically sound, but where do we see this in MVC? One place is reasonably clear - between the data-processing (Model) and the rest of the application.
Separation of Concern
04/13/2023Infobest Romania
Separation of Concern
04/13/2023Infobest Romania
Thus our models, controllers and views lie in logical/physical layers independent of each
other.
Separation of Concern
04/13/2023Infobest Romania
.NET MVC Framework
04/13/2023Infobest Romania
.NET Framework
04/13/2023Infobest Romania
Demo Create a project.How is it configured by default? Model, View Controller Razor Routing Friendly URLs Test driven dev Bundling Minification Validation Forms Send data to controller from view Form security
04/13/2023Infobest Romania
Demo : Create a project.How is it configured by default?
04/13/2023Infobest Romania
Demo : Model, View Controller
04/13/2023Infobest Romania
Demo : Razor
04/13/2023Infobest Romania
Demo : Routing
04/13/2023Infobest Romania
Demo : Friendly URLs
04/13/2023Infobest Romania
Demo : Test driven development
04/13/2023Infobest Romania
Demo : Bundling + Optimization
04/13/2023Infobest Romania
”In addition, the facility exists to optimise (minify) the CSS and Script files for release builds, whilst at the same time providing normal scripts for debugging the web application.” http://johnnewcombe.net/blog/post/4
Demo : Bundling
04/13/2023Infobest Romania
04/13/2023Infobest Romania
Demo : Bundling
04/13/2023Infobest Romania
Demo : Bundling
04/13/2023Infobest Romania
BundleTable.EnableOptimizations = true;
Demo : Bundling
04/13/2023Infobest Romania
Resources http://
www.asp.net/mvc/tutorials/mvc-4/bundling-and-minification
https://www.youtube.com/watch?v=y4ceKd-JSqc
Bundling
04/13/2023Infobest Romania
Demo : Model Validation
04/13/2023Infobest Romania
@using (Html.BeginForm("Index", "Test")) { … <input type=“submit”
id=“submitIndexView”/> }
Demo : Forms
04/13/2023Infobest Romania
@using (Html.BeginForm("Index", “Test“ ,new {argTest = "someText"}))
{ … <input type=“submit”
id=“submitIndexView”/> }
Demo : Send data to controller from view
04/13/2023Infobest Romania
For View @Html.AntiForgeryToken()
For Controller [HttpPost] [ValidateAntiForgeryToken]
Demo : Form security
04/13/2023Infobest Romania
Thanks!Claudiu Socaci