• A design Pattern (Methodology)
• Invented by Smalltalk programmer (Trygve
Reenskaug 1979).
• Separation of Concerns / Single Responsibility
Principle
• More easily testable
M
Model
V
View
C
Controller
• Representation of domain data
• Business Logic
• Persistence mechanisms
• User Interface
• The representation of Model
• An intermediary between Model and View
• Application’s Brain (Handle user requests, bind
Data, return views)
Ok
C
Controller
M
Model
V
View
CreateInvoice (fact)
Create invoice (data)
fact = new Invoice ()
LatestInvoices ()
return view ("Last-Invoices", ListFact[])
ListFact[]
HTML
• Part of ASP.NET
• Not an upgrade or replacement for Web Forms
ASP.NET
Webforms MVC Webpages
• No server controls
• No ViewState
• No Code Behind
• Full control over html
• Unit Testing
• Separation of application tasks (No code Behind)
• Flexibility and Extensibility
• Friendly URLs (Routing)
• Scalability and Performance
• Supports existing ASP.NET features
(Authentication, Membership, roles, output
caching,…)
• Natural integration with Ajax
• View Engines
o Aspx
o Razor
• Layout
• Partial View
• Section
• HtmlHelper, AjaxHelper
• ActionLink
@Html.ActionLink(“Modifier", “Edit“, new {Id=3})
<a href="/Product/Edit/6">Modifier</a>
• Form Elements (Form, TextBox, Hidden,….)
@Html.TextBox(“Nom")
<input id=" Nom " type="text" value="" name=" Nom ">
• DropDownList
var db = new NorthwindDataContext();
IEnumerable<SelectListItem> items = db.Categories
.Select(c => new SelectListItem { Value = c.CategoryID.ToString(), Text = c.CategoryName });
ViewBag.Categories = items;
@Html.DropDownList("CategoryID",
(IEnumerable<SelectListItem>) ViewBag.Categories)
• Ajax ActionLink
@Ajax.ActionLink("Get Time", "GetTime", new AjaxOptions () {
UpdateTargetId="divTorefresh",
HttpMethod="GET"
})
<a href="/Home/GetTime" data-ajax-update="#divTorefresh"
data-ajax-mode="after" data-ajax-method="GET" data-
ajax="true">Get Time</a>
• Action Results
• Filters
• Caching
• ViewResult
• PartialViewResult
• JsonResult
• JavaScriptResult
• ContentResult
• FileResult
• RedirectResult
• Authorization filters
• Action filters
• Result filters
• Exception filters
[OutputCache(Duration=3600)]
Public ActionResult GetListCountries()
{
// Logic to get countries list
}
[OutputCache(Duration=3600, VaryByParam = "countryId")]
Public ActionResult GetListRegions(int countryId)
{
// Logic to get regions list
}
• Annotation
• Validation(Client Side & Server Side)
• Required
• DisplayName
• Range
• DataType
• StringLength
• Open source package manager for the .NET
Framework
• Provide the ability to produce and consume packages
• Bundling & Minification
• Web Api
• Template Mobile
• Asynchronous
• RealTime avec SignalR
Improve JavaScript and CSS files loading
• Minimize the Number of requests (Bundle in
one File)
• Reduce the size of files (remove spaces, enters
and comments)
Fully customizable and extensible
• Entity Framework
• Database First
• Model First
• Code First
• Object-relational mapping (ORM) Framework
• Gives an automated mechanism for Data Access
• Manipulate Data as Object
• Reduce hard coded Query
• Have inheritance relationships between entities
• Performing basic CRUD(Create, Read, Update, Delete)
• Existing DataBase
• Generate .Edmx From DataBase
• Use ObjectContext & DBContext
• Use T4 template (POCO)
• Empty Edmx Model
• Design th DB Schema
• Generate DataBase From Model
• Create Domain Models (Class)
• Generate DataBase From Domain Models
• Full Control Over Code
• No Autogenerated code
• User Authentification
• Authorization
• Cross-site request forgery
• Cross-site Scripting
• Forms Authentification
• Cookies
• Windows Authentification
• Windows Session
• Via IIS
• OAuth
• Facebook, google, Hotmail, twitter, etc.
• Role-based Authorization
• [Authorize(Roles = "Admin, Super User")]
• [Authorize(Users = "Betty, Johnny")]
• Malicious attack (Cross Domain)
• Using Forms
• Session hijacking
• Malicious attack Using Script Injection
• Inject Code Inside Pages
• Design pattern
• Removal of hard-coded dependencies
• Giving an object its instance variables (Dynamically)
Asp.net MVC training session
Asp.net MVC training session

Asp.net MVC training session

  • 2.
    • A designPattern (Methodology) • Invented by Smalltalk programmer (Trygve Reenskaug 1979). • Separation of Concerns / Single Responsibility Principle • More easily testable
  • 3.
    M Model V View C Controller • Representation ofdomain data • Business Logic • Persistence mechanisms • User Interface • The representation of Model • An intermediary between Model and View • Application’s Brain (Handle user requests, bind Data, return views)
  • 4.
    Ok C Controller M Model V View CreateInvoice (fact) Create invoice(data) fact = new Invoice () LatestInvoices () return view ("Last-Invoices", ListFact[]) ListFact[] HTML
  • 5.
    • Part ofASP.NET • Not an upgrade or replacement for Web Forms ASP.NET Webforms MVC Webpages
  • 6.
    • No servercontrols • No ViewState • No Code Behind • Full control over html • Unit Testing
  • 7.
    • Separation ofapplication tasks (No code Behind) • Flexibility and Extensibility • Friendly URLs (Routing) • Scalability and Performance • Supports existing ASP.NET features (Authentication, Membership, roles, output caching,…) • Natural integration with Ajax
  • 9.
    • View Engines oAspx o Razor • Layout • Partial View • Section • HtmlHelper, AjaxHelper
  • 10.
    • ActionLink @Html.ActionLink(“Modifier", “Edit“,new {Id=3}) <a href="/Product/Edit/6">Modifier</a> • Form Elements (Form, TextBox, Hidden,….) @Html.TextBox(“Nom") <input id=" Nom " type="text" value="" name=" Nom ">
  • 11.
    • DropDownList var db= new NorthwindDataContext(); IEnumerable<SelectListItem> items = db.Categories .Select(c => new SelectListItem { Value = c.CategoryID.ToString(), Text = c.CategoryName }); ViewBag.Categories = items; @Html.DropDownList("CategoryID", (IEnumerable<SelectListItem>) ViewBag.Categories)
  • 12.
    • Ajax ActionLink @Ajax.ActionLink("GetTime", "GetTime", new AjaxOptions () { UpdateTargetId="divTorefresh", HttpMethod="GET" }) <a href="/Home/GetTime" data-ajax-update="#divTorefresh" data-ajax-mode="after" data-ajax-method="GET" data- ajax="true">Get Time</a>
  • 14.
    • Action Results •Filters • Caching
  • 15.
    • ViewResult • PartialViewResult •JsonResult • JavaScriptResult • ContentResult • FileResult • RedirectResult
  • 16.
    • Authorization filters •Action filters • Result filters • Exception filters
  • 17.
    [OutputCache(Duration=3600)] Public ActionResult GetListCountries() { //Logic to get countries list } [OutputCache(Duration=3600, VaryByParam = "countryId")] Public ActionResult GetListRegions(int countryId) { // Logic to get regions list }
  • 19.
  • 20.
    • Required • DisplayName •Range • DataType • StringLength
  • 22.
    • Open sourcepackage manager for the .NET Framework • Provide the ability to produce and consume packages
  • 24.
    • Bundling &Minification • Web Api • Template Mobile • Asynchronous • RealTime avec SignalR
  • 25.
    Improve JavaScript andCSS files loading • Minimize the Number of requests (Bundle in one File) • Reduce the size of files (remove spaces, enters and comments) Fully customizable and extensible
  • 29.
    • Entity Framework •Database First • Model First • Code First
  • 30.
    • Object-relational mapping(ORM) Framework • Gives an automated mechanism for Data Access • Manipulate Data as Object • Reduce hard coded Query • Have inheritance relationships between entities • Performing basic CRUD(Create, Read, Update, Delete)
  • 32.
    • Existing DataBase •Generate .Edmx From DataBase • Use ObjectContext & DBContext • Use T4 template (POCO)
  • 33.
    • Empty EdmxModel • Design th DB Schema • Generate DataBase From Model
  • 34.
    • Create DomainModels (Class) • Generate DataBase From Domain Models • Full Control Over Code • No Autogenerated code
  • 36.
    • User Authentification •Authorization • Cross-site request forgery • Cross-site Scripting
  • 37.
    • Forms Authentification •Cookies • Windows Authentification • Windows Session • Via IIS • OAuth • Facebook, google, Hotmail, twitter, etc.
  • 38.
    • Role-based Authorization •[Authorize(Roles = "Admin, Super User")] • [Authorize(Users = "Betty, Johnny")]
  • 39.
    • Malicious attack(Cross Domain) • Using Forms • Session hijacking
  • 40.
    • Malicious attackUsing Script Injection • Inject Code Inside Pages
  • 42.
    • Design pattern •Removal of hard-coded dependencies • Giving an object its instance variables (Dynamically)