SlideShare una empresa de Scribd logo
1 de 22
ASP.NET MVC
Practice and Guideline
Zubzib Black Coffee #7
About me
                      • Chalermpon Areepong (Nine)




 • Microsoft MVP ASP.NET




 • Work @
Session Level 300
Audience Skill
• HTML
• JavaScript
• C#
• OOP
• LINQ
Agenda
• Basic ASP.NET MVC Programming
    o   Model
    o   View
    o   Controller
    o   Routes

•   NuGet Package Manager
•   Entity Framework 4.x Code First Introduce
•   Application Layer Architecture
•   Repository Pattern
•   Dependency Injection
Basic of ASP.NET MVC
Programing
• Model :
   o Class Model, Domain Transfer Object (DTO), View Model
   o Model Validation
      • Validation Attribute, IValidationObject Interface

• View : User Interface
   o Engine : ASPX ViewEngine, Razor ViewEngine, Etc……
   o HTML, CSS, JavaScript

• Controller
   o   Control logic,
   o   Data access,
   o   Prepare parameters for view render
   o   call view to render output
Basic of ASP.NET MVC
Programing
• DEMO
Basic of ASP.NET MVC
 Programing
• Routes
  o Catch URL to parameter by pattern
     • Default
               “{controller}/{action}/{id}”
               http://www.zz.com/blog/get/1
     • Fix route value
               new { controller = “blog”, action = “get”, id = 1 }
     • Custom Routes
          o blog/Archive/12-25-2009
               “{controller}/{action}/{date}”
               http://www.zz.com/blog/Archive/12-25-2009
               Public ActionResult Archive(DateTime date)
          o blog/Archive/12-25-2009_12-17-2011
               “{controller}/{action}/{dateFrom}_{dateTo}”
               http://www.zz.com/blog/Archive/12-25-2009_12-17-2011
               public ActionResult Archive(DateTime dateFrom, DateTime DateTo)
Basic of ASP.NET MVC
 Programing
• Routes DEMO
NuGet Package Manager
• Library Utility for
   o Search
   o Install / Update / Uninstall
   o Execute library command (PowerShell)

• VS - > Menu -> Tools -> Extension Manager -> Find
  NuGet and install
• How to use
   o Project Reference
   o Package Manager Console
       • Install-Package <package name>
       • Uninstall-Package <package name>
       • Get-Package
NuGet Package Manager
• DEMO
EF 4.x Code First
•   Object Relational Mapping
•   POCO
•   Convention Over Configuration
•   LINQ Support
•   Working with various database (3rd party driver)
•   Fluent API to fully customize the persistence
    mapping

• Demo…..
EF 4.x Code First
• DEMO
MVC UI Library
All will render to HTML/ CSS / JavaScript
• JQuery UI
• Telerik MVC Extension (current not full support
   HTML5)
• Knockout (MVVM)
• Kendo UI (HTML5)
• Wijmo (HTML5)
MVC UI Library
• DEMO
Software Design:
Repository Pattern
• Encapsulate data access
• Simple collection like interface
• Should only return aggregate roots
• Provide for adding and removing entities
• Provide methods to select objects based on some
  criteria
• Allow easy substitution
Software Design:
Repository Pattern
• DEMO
Software Design:
Core Layer Architecture
Motivation – Logical layers separate the major
concerns of the application:
• 1. Modularity, low-coupling – easier maintenance.
• 2. Business-logic is separated from presentation –
  reuse.
• 3. General technical services, e.g., database, are
  separated from the business-logic –
  reused, replaced.
• 4. Low coupling, separation of concerns – evolving
  functionality, system scaling-up, adapt to new
  technologies.
Software Design:
Core Layer Architecture
Software Design:
Core Layer Architecture
• DEMO
Dependency Injection
• Dependency Injection - one example of IoC design
  principle.
• Also known as the Hollywood Principle
   o Don’t call us, we’ll call you!
• Good OO Systems – organised as web of interacting
  objects

• Goal – High cohesion, low coupling
• Advantages of low coupling
   o Extensibility
   o Testability
   o Reusability


PS>Not so easy to achieve!
Dependency Injection
• Demo
Summary
•   ASP.NET MVC
•   NuGet
•   EF Code First
•   JavaScript Framework
•   AutoFac MVC Integration

• Bye…

Más contenido relacionado

La actualidad más candente

Intro to SPA using JavaScript & ASP.NET
Intro to SPA using JavaScript & ASP.NETIntro to SPA using JavaScript & ASP.NET
Intro to SPA using JavaScript & ASP.NET
Alan Hecht
 
Javascript frameworks: Backbone.js
Javascript frameworks: Backbone.jsJavascript frameworks: Backbone.js
Javascript frameworks: Backbone.js
Soós Gábor
 

La actualidad más candente (20)

AngularJS Basics
AngularJS BasicsAngularJS Basics
AngularJS Basics
 
JavaCro'14 - Building interactive web applications with Vaadin – Peter Lehto
JavaCro'14 - Building interactive web applications with Vaadin – Peter LehtoJavaCro'14 - Building interactive web applications with Vaadin – Peter Lehto
JavaCro'14 - Building interactive web applications with Vaadin – Peter Lehto
 
[2015/2016] Local data storage for web-based mobile apps
[2015/2016] Local data storage for web-based mobile apps[2015/2016] Local data storage for web-based mobile apps
[2015/2016] Local data storage for web-based mobile apps
 
Zend framework 02 - mvc
Zend framework 02 - mvcZend framework 02 - mvc
Zend framework 02 - mvc
 
Beyond PrettyFaces - Einführung in Rewrite
Beyond PrettyFaces - Einführung in RewriteBeyond PrettyFaces - Einführung in Rewrite
Beyond PrettyFaces - Einführung in Rewrite
 
Angularjs Basics
Angularjs BasicsAngularjs Basics
Angularjs Basics
 
Alex Thissen "Server-less compute with .NET based Azure Functions"
Alex Thissen "Server-less compute with .NET based Azure Functions"Alex Thissen "Server-less compute with .NET based Azure Functions"
Alex Thissen "Server-less compute with .NET based Azure Functions"
 
[2015/2016] Require JS and Handlebars JS
[2015/2016] Require JS and Handlebars JS[2015/2016] Require JS and Handlebars JS
[2015/2016] Require JS and Handlebars JS
 
Everything you need to know about HTML5 in 15 min
Everything you need to know about HTML5 in 15 minEverything you need to know about HTML5 in 15 min
Everything you need to know about HTML5 in 15 min
 
Beyond PrettyFaces - Einführung in Rewrite
Beyond PrettyFaces - Einführung in RewriteBeyond PrettyFaces - Einführung in Rewrite
Beyond PrettyFaces - Einführung in Rewrite
 
SenchaCon 2016: A Look Ahead: Survey Next-Gen Modern Browser APIs - Shikhir S...
SenchaCon 2016: A Look Ahead: Survey Next-Gen Modern Browser APIs - Shikhir S...SenchaCon 2016: A Look Ahead: Survey Next-Gen Modern Browser APIs - Shikhir S...
SenchaCon 2016: A Look Ahead: Survey Next-Gen Modern Browser APIs - Shikhir S...
 
Atlanta JUG - Integrating Spring Batch and Spring Integration
Atlanta JUG - Integrating Spring Batch and Spring IntegrationAtlanta JUG - Integrating Spring Batch and Spring Integration
Atlanta JUG - Integrating Spring Batch and Spring Integration
 
AngularJS
AngularJSAngularJS
AngularJS
 
A Good PHP Framework For Beginners Like Me!
A Good PHP Framework For Beginners Like Me!A Good PHP Framework For Beginners Like Me!
A Good PHP Framework For Beginners Like Me!
 
ASP .NET MVC - best practices
ASP .NET MVC - best practicesASP .NET MVC - best practices
ASP .NET MVC - best practices
 
.NET,ASP .NET, Angular Js,LinQ
.NET,ASP .NET, Angular Js,LinQ.NET,ASP .NET, Angular Js,LinQ
.NET,ASP .NET, Angular Js,LinQ
 
Codeinator
CodeinatorCodeinator
Codeinator
 
Intro to SPA using JavaScript & ASP.NET
Intro to SPA using JavaScript & ASP.NETIntro to SPA using JavaScript & ASP.NET
Intro to SPA using JavaScript & ASP.NET
 
Introduction to Node.js Platform
Introduction to Node.js PlatformIntroduction to Node.js Platform
Introduction to Node.js Platform
 
Javascript frameworks: Backbone.js
Javascript frameworks: Backbone.jsJavascript frameworks: Backbone.js
Javascript frameworks: Backbone.js
 

Similar a ZZ BC#7 asp.net mvc practice and guideline by NineMvp

SoCal Code Camp 2011 - ASP.NET 4.5
SoCal Code Camp 2011 - ASP.NET 4.5SoCal Code Camp 2011 - ASP.NET 4.5
SoCal Code Camp 2011 - ASP.NET 4.5
Jon Galloway
 
Apache Cayenne for WO Devs
Apache Cayenne for WO DevsApache Cayenne for WO Devs
Apache Cayenne for WO Devs
WO Community
 

Similar a ZZ BC#7 asp.net mvc practice and guideline by NineMvp (20)

2011 NetUG HH: ASP.NET MVC & HTML 5
2011 NetUG HH: ASP.NET MVC & HTML 52011 NetUG HH: ASP.NET MVC & HTML 5
2011 NetUG HH: ASP.NET MVC & HTML 5
 
MVC 6 - the new unified Web programming model
MVC 6 - the new unified Web programming modelMVC 6 - the new unified Web programming model
MVC 6 - the new unified Web programming model
 
SoCal Code Camp 2011 - ASP.NET 4.5
SoCal Code Camp 2011 - ASP.NET 4.5SoCal Code Camp 2011 - ASP.NET 4.5
SoCal Code Camp 2011 - ASP.NET 4.5
 
Introduction Asp.Net MVC5 |MVC5 Tutorial for Beginners & Advanced | Dot Net T...
Introduction Asp.Net MVC5 |MVC5 Tutorial for Beginners & Advanced | Dot Net T...Introduction Asp.Net MVC5 |MVC5 Tutorial for Beginners & Advanced | Dot Net T...
Introduction Asp.Net MVC5 |MVC5 Tutorial for Beginners & Advanced | Dot Net T...
 
Plantilla oracle
Plantilla oraclePlantilla oracle
Plantilla oracle
 
Apache Cayenne for WO Devs
Apache Cayenne for WO DevsApache Cayenne for WO Devs
Apache Cayenne for WO Devs
 
Sitecore MVC: Converting Web Forms sublayouts
Sitecore MVC: Converting Web Forms sublayoutsSitecore MVC: Converting Web Forms sublayouts
Sitecore MVC: Converting Web Forms sublayouts
 
Power of Azure Devops
Power of Azure DevopsPower of Azure Devops
Power of Azure Devops
 
Asp 1a-aspnetmvc
Asp 1a-aspnetmvcAsp 1a-aspnetmvc
Asp 1a-aspnetmvc
 
Aspnetmvc 1
Aspnetmvc 1Aspnetmvc 1
Aspnetmvc 1
 
Ow
OwOw
Ow
 
Introduction to ASP.NET 5
Introduction to ASP.NET 5Introduction to ASP.NET 5
Introduction to ASP.NET 5
 
70487.pdf
70487.pdf70487.pdf
70487.pdf
 
SOLID Programming with Portable Class Libraries
SOLID Programming with Portable Class LibrariesSOLID Programming with Portable Class Libraries
SOLID Programming with Portable Class Libraries
 
CFWheels - Pragmatic, Beautiful Code
CFWheels - Pragmatic, Beautiful CodeCFWheels - Pragmatic, Beautiful Code
CFWheels - Pragmatic, Beautiful Code
 
ow.ppt
ow.pptow.ppt
ow.ppt
 
ow.ppt
ow.pptow.ppt
ow.ppt
 
Ow
OwOw
Ow
 
Asp.net mvc presentation by Nitin Sawant
Asp.net mvc presentation by Nitin SawantAsp.net mvc presentation by Nitin Sawant
Asp.net mvc presentation by Nitin Sawant
 
ASP.NET vNext
ASP.NET vNextASP.NET vNext
ASP.NET vNext
 

Más de Chalermpon Areepong

Build your web app with asp.net mvc 2 from scratch
Build your web app with asp.net mvc 2 from scratchBuild your web app with asp.net mvc 2 from scratch
Build your web app with asp.net mvc 2 from scratch
Chalermpon Areepong
 

Más de Chalermpon Areepong (9)

DevRock #02 akka.net intro part
DevRock #02 akka.net intro partDevRock #02 akka.net intro part
DevRock #02 akka.net intro part
 
Web API authentication and authorization
Web API authentication and authorization Web API authentication and authorization
Web API authentication and authorization
 
Build your website with angularjs and web apis
Build your website with angularjs and web apisBuild your website with angularjs and web apis
Build your website with angularjs and web apis
 
Java script for web developer
Java script for web developerJava script for web developer
Java script for web developer
 
ASP.NET WEB API Training
ASP.NET WEB API TrainingASP.NET WEB API Training
ASP.NET WEB API Training
 
ZZ BC#8 Hello ASP.NET MVC 4 (dks)
ZZ BC#8 Hello ASP.NET MVC 4 (dks)ZZ BC#8 Hello ASP.NET MVC 4 (dks)
ZZ BC#8 Hello ASP.NET MVC 4 (dks)
 
Build your web app with asp.net mvc 2 from scratch
Build your web app with asp.net mvc 2 from scratchBuild your web app with asp.net mvc 2 from scratch
Build your web app with asp.net mvc 2 from scratch
 
Gf vtzz-05--j queryshowcase
Gf vtzz-05--j queryshowcaseGf vtzz-05--j queryshowcase
Gf vtzz-05--j queryshowcase
 
J query
J queryJ query
J query
 

Último

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Último (20)

Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 

ZZ BC#7 asp.net mvc practice and guideline by NineMvp

  • 1. ASP.NET MVC Practice and Guideline Zubzib Black Coffee #7
  • 2. About me • Chalermpon Areepong (Nine) • Microsoft MVP ASP.NET • Work @
  • 3. Session Level 300 Audience Skill • HTML • JavaScript • C# • OOP • LINQ
  • 4. Agenda • Basic ASP.NET MVC Programming o Model o View o Controller o Routes • NuGet Package Manager • Entity Framework 4.x Code First Introduce • Application Layer Architecture • Repository Pattern • Dependency Injection
  • 5. Basic of ASP.NET MVC Programing • Model : o Class Model, Domain Transfer Object (DTO), View Model o Model Validation • Validation Attribute, IValidationObject Interface • View : User Interface o Engine : ASPX ViewEngine, Razor ViewEngine, Etc…… o HTML, CSS, JavaScript • Controller o Control logic, o Data access, o Prepare parameters for view render o call view to render output
  • 6. Basic of ASP.NET MVC Programing • DEMO
  • 7. Basic of ASP.NET MVC Programing • Routes o Catch URL to parameter by pattern • Default “{controller}/{action}/{id}” http://www.zz.com/blog/get/1 • Fix route value new { controller = “blog”, action = “get”, id = 1 } • Custom Routes o blog/Archive/12-25-2009 “{controller}/{action}/{date}” http://www.zz.com/blog/Archive/12-25-2009 Public ActionResult Archive(DateTime date) o blog/Archive/12-25-2009_12-17-2011 “{controller}/{action}/{dateFrom}_{dateTo}” http://www.zz.com/blog/Archive/12-25-2009_12-17-2011 public ActionResult Archive(DateTime dateFrom, DateTime DateTo)
  • 8. Basic of ASP.NET MVC Programing • Routes DEMO
  • 9. NuGet Package Manager • Library Utility for o Search o Install / Update / Uninstall o Execute library command (PowerShell) • VS - > Menu -> Tools -> Extension Manager -> Find NuGet and install • How to use o Project Reference o Package Manager Console • Install-Package <package name> • Uninstall-Package <package name> • Get-Package
  • 11. EF 4.x Code First • Object Relational Mapping • POCO • Convention Over Configuration • LINQ Support • Working with various database (3rd party driver) • Fluent API to fully customize the persistence mapping • Demo…..
  • 12. EF 4.x Code First • DEMO
  • 13. MVC UI Library All will render to HTML/ CSS / JavaScript • JQuery UI • Telerik MVC Extension (current not full support HTML5) • Knockout (MVVM) • Kendo UI (HTML5) • Wijmo (HTML5)
  • 15. Software Design: Repository Pattern • Encapsulate data access • Simple collection like interface • Should only return aggregate roots • Provide for adding and removing entities • Provide methods to select objects based on some criteria • Allow easy substitution
  • 17. Software Design: Core Layer Architecture Motivation – Logical layers separate the major concerns of the application: • 1. Modularity, low-coupling – easier maintenance. • 2. Business-logic is separated from presentation – reuse. • 3. General technical services, e.g., database, are separated from the business-logic – reused, replaced. • 4. Low coupling, separation of concerns – evolving functionality, system scaling-up, adapt to new technologies.
  • 19. Software Design: Core Layer Architecture • DEMO
  • 20. Dependency Injection • Dependency Injection - one example of IoC design principle. • Also known as the Hollywood Principle o Don’t call us, we’ll call you! • Good OO Systems – organised as web of interacting objects • Goal – High cohesion, low coupling • Advantages of low coupling o Extensibility o Testability o Reusability PS>Not so easy to achieve!
  • 22. Summary • ASP.NET MVC • NuGet • EF Code First • JavaScript Framework • AutoFac MVC Integration • Bye…