SlideShare a Scribd company logo
ASP.NET: Building Web Application… in the right way
ASP.NET a brief history
• 2001 – first release
• 2009 – ASP.NET MVC
• 2012 – ASP.NET Web API
• 2013 – OWIN and SignalR
• 2015 – ASP.NET 5 (RC1)
MVC pattern
notifies
Controller
Model
View
interacts
with
modifies
modifies
listens /
gets data from
MVC web style
Webpageinteracts
with
Controller
Model
View
selects a
passes a model to
acts on
gets data fromproduces
invokes
ASP.NET MVC
• A new presentation option for ASP.NET
• Simpler way to program ASP.NET
• Easily testable and TDD friendly
• More control over your <html/>
• More control over your URLs
• Supports existing ASP.NET features
• Removes: viewstate and postback needs
Routing
Webpageinteracts
with
Controller
Model
View
selects a
passes a model to
acts on
gets data fromproduces
invokes
Routing - example
public class OrdersController : Controller
{
public ActionResult Index()
{
}
public ActionResult Details(int id)
{
}
}
http://www.yoursite.com/Orders/Details/1
Routing - example
http://www.yoursite.com/Orders/Details/1
public class OrdersController : Controller
{
public ActionResult Index()
{
}
public ActionResult Details(int id)
{
}
}
Routing - example
http://www.yoursite.com/Orders/Details/1
public class OrdersController : Controller
{
public ActionResult Index()
{
}
public ActionResult Details(int id)
{
}
}
Routing – configuration
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home",
action = "Index", id = UrlParameter.Optional });
}
Routing – configuration
routes.MapMvcAttributeRoutes();
//
public class OrdersController : Controller
{
[Route("Orders/{id}/Items")]
public ActionResult OrderItems(int id)
{
}
}
http://www.yoursite.com/Orders/1/Items
Controller
Webpageinteracts
with
Controller
Model
View
selects a
passes a model to
acts on
gets data fromproduces
invokes
Controller
public class OrdersController : Controller
{
public ActionResult Details(int? id)
{
Order order = db.Orders.Find(id);
if (order == null)
return HttpNotFound();
return View(order);
}
}
View("MyWonderfulOrderView", order);
Controller – routing and HTTP methods
public class OrdersController : Controller
{
// GET: Orders/Edit/5
public ActionResult Edit(int? id)
{
}
// POST: Orders/Edit/5
[HttpPost]
public ActionResult Edit(Order order)
{
}
}
Model
Webpageinteracts
with
Controller
Model
View
selects a
passes a model to
acts on
gets data fromproduces
invokes
Model
• View Model or Business Model
• Validation attributes, for example:
• Required
• EmailAddress
• StringLength
• View-related attributes, e.g. Display
public class LoginViewModel
{
[Required]
[Display(Name = "Email address")]
[EmailAddress]
public string Email { get; set; }
[Required]
[DataType(DataType.Password)]
[Display(Name = "Password")]
public string Password { get; set; }
[Display(Name = "Remember me")]
public bool RememberMe { get; set; }
}
View
Webpageinteracts
with
Controller
Model
View
selects a
passes a model to
acts on
gets data fromproduces
invokes
View
• Related to controllers/actions by naming convetion
• Several View Engine. Standard: Razor, WebFormViewEngine
• Support layouts and partial views
• Can use strongly-typed model (e.g. Order) or dynamic one (ViewBag)
• @Html helper methods (e.g. @Html.TextBoxFor)
• @Html methods can be extended
ActionResult
• ActionResult is the base class for action’s return types
• Available results:
• ViewResult - Renders a specifed view to the response stream
• RedirectResult - Performs an HTTP redirection to a specifed URL
• RedirectToRouteResult - Performs an HTTP redirection to a URL that is determined by
the routing engine, based on given route data
• JsonResult - Serializes a given ViewData object to JSON format
• ContentResult - Writes content to the response stream without requiring a view
• FileContentResult - Returns a file to the client
• and more
Model binder
• Transform values from client to .NET class instances or primitive types
• Retrieves values from HTML form variables, POSTed variables, query string
and routing parameters
• DefaultModelBinder is the default binder
• Binding can be customized, for specific types at application level or at action’s
parameter level
Filters
• Enable Aspect Oriented Programming (AOP)
• Different types for different needs:
• Authorization filters – IAuthorizationFilter
• Action filters – IActionFilter
• Result filters – IResultFilter
• Exception filters – IExceptionFilter
• Filters can be applied to a single action or a whole controller
Q&A
Q&A
ASP.NET Web API
• Formerly part of WCF framework
• 2012 – First release
• 2013 – Release of Web API 2
• First class framework for HTTP-based services
• Foundamental for creating RESTful services
• Self-hosted
• Different stacks, same concepts – System.Web.Mvc  System.Web.Http
ASP.NET Web API cf. MVC
• Similar route patterns declarations
• Request/method name matching by HTTP verbs
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
ASP.NET Web API cf. MVC
GET http://www.yoursite.com/api/Orders/5
public class OrdersController : ApiController
{
IQueryable<Order> GetOrders() { … }
IHttpActionResult GetOrder(int id) { … }
IHttpActionResult PutOrder(int id, Order order) { … }
IHttpActionResult PostOrder(Order order) { … }
IHttpActionResult DeleteOrder(int id) { … }
}
ASP.NET Web API cf. MVC
• No views or ActionResult just data or IHttpActionResult
• Data are serialized in JSON or other format (e.g. XML)
• Controllers inherit from ApiController
• No more HttpContext.Current
• View filters
ASP.NET Web API - OData
“An open protocol to allow the creation and consumption of queryable and
interoperable RESTful APIs in a simple and standard way”
EnableQueryAttribute
Implements out of the box most of the OData query system: filters, pagination,
projection, etc.
Let’s go to code
Let’s go to code
Q&A
Q&A
What’s next? ASP.NET 5
ASP.NET 5 – .NET Core
• Totally modular
• Faster development cycle
• Seamless transition from on-premises to cloud
• Choose your editor and tools
• Open-source
• Cross-platform
• Fast
ASP.NET 5 cf. ASP.NET 4.X
• No more Web Forms and Web API only MVC
• One ring stack to rule them all, i.e. no more double coding
• Tag helpers – cleaner HTML views
• Project and configuration files in JSON
• Server side and client side packages completelly decoupled
• much more 
thank you for your attention
stay tuned for next workshops
Andrea Vallotti, ph.D
andrea.vallotti@commitsoftware.it

More Related Content

What's hot

Building dynamic applications with the share point client object model
Building dynamic applications with the share point client object modelBuilding dynamic applications with the share point client object model
Building dynamic applications with the share point client object modelEric Shupps
 
Angular js for Beginnners
Angular js for BeginnnersAngular js for Beginnners
Angular js for Beginnners
Santosh Kumar Kar
 
RichControl in Asp.net
RichControl in Asp.netRichControl in Asp.net
RichControl in Asp.netBhumivaghasiya
 
Standard List Controllers
Standard List Controllers Standard List Controllers
Standard List Controllers
Mohammed Safwat Abu Kwaik
 
JavaLand 2014 - Ankor.io Presentation
JavaLand 2014 - Ankor.io PresentationJavaLand 2014 - Ankor.io Presentation
JavaLand 2014 - Ankor.io Presentation
manolitto
 
Introduction to ajax
Introduction to ajaxIntroduction to ajax
Introduction to ajax
Nir Elbaz
 
AngularJS 1.x - your first application (problems and solutions)
AngularJS 1.x - your first application (problems and solutions)AngularJS 1.x - your first application (problems and solutions)
AngularJS 1.x - your first application (problems and solutions)
Igor Talevski
 
Asp.net server controls
Asp.net server controlsAsp.net server controls
Asp.net server controlsRaed Aldahdooh
 
Ankor Presentation @ JavaOne San Francisco September 2014
Ankor Presentation @ JavaOne San Francisco September 2014Ankor Presentation @ JavaOne San Francisco September 2014
Ankor Presentation @ JavaOne San Francisco September 2014
manolitto
 
Asp.net mvc 6 with sql server 2014
Asp.net mvc 6 with sql server 2014Asp.net mvc 6 with sql server 2014
Asp.net mvc 6 with sql server 2014
Fahim Faysal Kabir
 
Presentation on asp.net controls
Presentation on asp.net controlsPresentation on asp.net controls
Presentation on asp.net controls
Reshi Unen
 
Sitecore MVC (User Group Conference, May 23rd 2014)
Sitecore MVC (User Group Conference, May 23rd 2014)Sitecore MVC (User Group Conference, May 23rd 2014)
Sitecore MVC (User Group Conference, May 23rd 2014)
Ruud van Falier
 
Asp.Net MVC
Asp.Net MVCAsp.Net MVC
Asp.Net MVC
Sudheesh Valathil
 
Tech Talk Live on Share Extensibility
Tech Talk Live on Share ExtensibilityTech Talk Live on Share Extensibility
Tech Talk Live on Share Extensibility
Alfresco Software
 
SFDC UI - Introduction to Visualforce
SFDC UI -  Introduction to VisualforceSFDC UI -  Introduction to Visualforce
SFDC UI - Introduction to Visualforce
Sujit Kumar
 
Getting a Quick Start with Visualforce
Getting a Quick Start with Visualforce Getting a Quick Start with Visualforce
Getting a Quick Start with Visualforce
Mohammed Safwat Abu Kwaik
 
Advance java session 15
Advance java session 15Advance java session 15
Advance java session 15
Smita B Kumar
 

What's hot (20)

Building dynamic applications with the share point client object model
Building dynamic applications with the share point client object modelBuilding dynamic applications with the share point client object model
Building dynamic applications with the share point client object model
 
Angular js for Beginnners
Angular js for BeginnnersAngular js for Beginnners
Angular js for Beginnners
 
RichControl in Asp.net
RichControl in Asp.netRichControl in Asp.net
RichControl in Asp.net
 
Standard List Controllers
Standard List Controllers Standard List Controllers
Standard List Controllers
 
JavaLand 2014 - Ankor.io Presentation
JavaLand 2014 - Ankor.io PresentationJavaLand 2014 - Ankor.io Presentation
JavaLand 2014 - Ankor.io Presentation
 
Introduction to ajax
Introduction to ajaxIntroduction to ajax
Introduction to ajax
 
AngularJS 1.x - your first application (problems and solutions)
AngularJS 1.x - your first application (problems and solutions)AngularJS 1.x - your first application (problems and solutions)
AngularJS 1.x - your first application (problems and solutions)
 
Asp.net server controls
Asp.net server controlsAsp.net server controls
Asp.net server controls
 
Ankor Presentation @ JavaOne San Francisco September 2014
Ankor Presentation @ JavaOne San Francisco September 2014Ankor Presentation @ JavaOne San Francisco September 2014
Ankor Presentation @ JavaOne San Francisco September 2014
 
Asp.net mvc 6 with sql server 2014
Asp.net mvc 6 with sql server 2014Asp.net mvc 6 with sql server 2014
Asp.net mvc 6 with sql server 2014
 
Presentation on asp.net controls
Presentation on asp.net controlsPresentation on asp.net controls
Presentation on asp.net controls
 
Sitecore MVC (User Group Conference, May 23rd 2014)
Sitecore MVC (User Group Conference, May 23rd 2014)Sitecore MVC (User Group Conference, May 23rd 2014)
Sitecore MVC (User Group Conference, May 23rd 2014)
 
Asp.Net MVC
Asp.Net MVCAsp.Net MVC
Asp.Net MVC
 
Controls in asp.net
Controls in asp.netControls in asp.net
Controls in asp.net
 
Tech Talk Live on Share Extensibility
Tech Talk Live on Share ExtensibilityTech Talk Live on Share Extensibility
Tech Talk Live on Share Extensibility
 
SFDC UI - Introduction to Visualforce
SFDC UI -  Introduction to VisualforceSFDC UI -  Introduction to Visualforce
SFDC UI - Introduction to Visualforce
 
Getting a Quick Start with Visualforce
Getting a Quick Start with Visualforce Getting a Quick Start with Visualforce
Getting a Quick Start with Visualforce
 
Ajax
AjaxAjax
Ajax
 
Standard control in asp.net
Standard control in asp.netStandard control in asp.net
Standard control in asp.net
 
Advance java session 15
Advance java session 15Advance java session 15
Advance java session 15
 

Viewers also liked

Trabajando la convivencia
Trabajando la convivenciaTrabajando la convivencia
Trabajando la convivencia
MoniHdz04
 
โครงสร้างข้อมูล
โครงสร้างข้อมูลโครงสร้างข้อมูล
โครงสร้างข้อมูล
korn27122540
 
ลักษณะเด่นของคอมพิวเตอร์ 8
ลักษณะเด่นของคอมพิวเตอร์ 8ลักษณะเด่นของคอมพิวเตอร์ 8
ลักษณะเด่นของคอมพิวเตอร์ 8
korn27122540
 
Team 4 Capstone - Subsidium - Final
Team 4 Capstone - Subsidium - FinalTeam 4 Capstone - Subsidium - Final
Team 4 Capstone - Subsidium - FinalMichael Hoke
 
Taleah Coxs Resume_2016 TX
Taleah Coxs Resume_2016 TXTaleah Coxs Resume_2016 TX
Taleah Coxs Resume_2016 TXTaleah Bridwell
 
Jardins do Paço - Jardins Verticais
Jardins do Paço - Jardins VerticaisJardins do Paço - Jardins Verticais
Jardins do Paço - Jardins Verticais
Francisco Sousa Machado
 
Jardins do Paço - Arquitectura Paisagista
Jardins do Paço - Arquitectura PaisagistaJardins do Paço - Arquitectura Paisagista
Jardins do Paço - Arquitectura Paisagista
Francisco Sousa Machado
 
Jardins do Paço Landscaping
Jardins do Paço LandscapingJardins do Paço Landscaping
Jardins do Paço Landscaping
Francisco Sousa Machado
 
Jardins do Paço Paysagisme
Jardins do Paço PaysagismeJardins do Paço Paysagisme
Jardins do Paço Paysagisme
Francisco Sousa Machado
 
Jardins do Paço - Green walls
Jardins do Paço - Green wallsJardins do Paço - Green walls
Jardins do Paço - Green walls
Francisco Sousa Machado
 
Intro to Hybrid Mobile Development && Ionic
Intro to Hybrid Mobile Development && IonicIntro to Hybrid Mobile Development && Ionic
Intro to Hybrid Mobile Development && Ionic
Fioriela Bego
 

Viewers also liked (11)

Trabajando la convivencia
Trabajando la convivenciaTrabajando la convivencia
Trabajando la convivencia
 
โครงสร้างข้อมูล
โครงสร้างข้อมูลโครงสร้างข้อมูล
โครงสร้างข้อมูล
 
ลักษณะเด่นของคอมพิวเตอร์ 8
ลักษณะเด่นของคอมพิวเตอร์ 8ลักษณะเด่นของคอมพิวเตอร์ 8
ลักษณะเด่นของคอมพิวเตอร์ 8
 
Team 4 Capstone - Subsidium - Final
Team 4 Capstone - Subsidium - FinalTeam 4 Capstone - Subsidium - Final
Team 4 Capstone - Subsidium - Final
 
Taleah Coxs Resume_2016 TX
Taleah Coxs Resume_2016 TXTaleah Coxs Resume_2016 TX
Taleah Coxs Resume_2016 TX
 
Jardins do Paço - Jardins Verticais
Jardins do Paço - Jardins VerticaisJardins do Paço - Jardins Verticais
Jardins do Paço - Jardins Verticais
 
Jardins do Paço - Arquitectura Paisagista
Jardins do Paço - Arquitectura PaisagistaJardins do Paço - Arquitectura Paisagista
Jardins do Paço - Arquitectura Paisagista
 
Jardins do Paço Landscaping
Jardins do Paço LandscapingJardins do Paço Landscaping
Jardins do Paço Landscaping
 
Jardins do Paço Paysagisme
Jardins do Paço PaysagismeJardins do Paço Paysagisme
Jardins do Paço Paysagisme
 
Jardins do Paço - Green walls
Jardins do Paço - Green wallsJardins do Paço - Green walls
Jardins do Paço - Green walls
 
Intro to Hybrid Mobile Development && Ionic
Intro to Hybrid Mobile Development && IonicIntro to Hybrid Mobile Development && Ionic
Intro to Hybrid Mobile Development && Ionic
 

Similar to ASP.NET - Building Web Application..in the right way!

Using MVC with Kentico 8
Using MVC with Kentico 8Using MVC with Kentico 8
Using MVC with Kentico 8
Thomas Robbins
 
Asp.net With mvc handson
Asp.net With mvc handsonAsp.net With mvc handson
Asp.net With mvc handson
Prashant Kumar
 
Asp 1-mvc introduction
Asp 1-mvc introductionAsp 1-mvc introduction
Asp 1-mvc introduction
Fajar Baskoro
 
MVC & SQL_In_1_Hour
MVC & SQL_In_1_HourMVC & SQL_In_1_Hour
MVC & SQL_In_1_HourDilip Patel
 
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
Daniel Fisher
 
ASP.NET MVC_Routing_Authentication_Aurhorization.pdf
ASP.NET MVC_Routing_Authentication_Aurhorization.pdfASP.NET MVC_Routing_Authentication_Aurhorization.pdf
ASP.NET MVC_Routing_Authentication_Aurhorization.pdf
setit72024
 
ASP.NET MVC 2.0
ASP.NET MVC 2.0ASP.NET MVC 2.0
ASP.NET MVC 2.0
Buu Nguyen
 
Web api
Web apiWeb api
Web api
udaiappa
 
Introduction to ASP.NET MVC
Introduction to ASP.NET MVC Introduction to ASP.NET MVC
Introduction to ASP.NET MVC
Joe Wilson
 
Simple mvc4 prepared by gigin krishnan
Simple mvc4 prepared by gigin krishnanSimple mvc4 prepared by gigin krishnan
Simple mvc4 prepared by gigin krishnan
Gigin Krishnan
 
SoftServe - "ASP.NET MVC як наступний крок у розвитку технології розробки Web...
SoftServe - "ASP.NET MVC як наступний крок у розвитку технології розробки Web...SoftServe - "ASP.NET MVC як наступний крок у розвитку технології розробки Web...
SoftServe - "ASP.NET MVC як наступний крок у розвитку технології розробки Web...
SoftServe
 
ASP.NET MVC introduction
ASP.NET MVC introductionASP.NET MVC introduction
ASP.NET MVC introduction
Tomi Juhola
 
ASP.NET MVC 5 - EF 6 - VS2015
ASP.NET MVC 5 - EF 6 - VS2015ASP.NET MVC 5 - EF 6 - VS2015
ASP.NET MVC 5 - EF 6 - VS2015
Hossein Zahed
 
(ATS6-DEV03) Building an Enterprise Web Solution with AEP
(ATS6-DEV03) Building an Enterprise Web Solution with AEP(ATS6-DEV03) Building an Enterprise Web Solution with AEP
(ATS6-DEV03) Building an Enterprise Web Solution with AEP
BIOVIA
 
Sitecore MVC: What it is and why it's important
Sitecore MVC: What it is and why it's importantSitecore MVC: What it is and why it's important
Sitecore MVC: What it is and why it's important
nonlinear creations
 
Web Development using ASP.NET MVC at HEC
Web Development using ASP.NET MVC at HECWeb Development using ASP.NET MVC at HEC
Web Development using ASP.NET MVC at HECAdil Mughal
 
Getting started with MVC 5 and Visual Studio 2013
Getting started with MVC 5 and Visual Studio 2013Getting started with MVC 5 and Visual Studio 2013
Getting started with MVC 5 and Visual Studio 2013
Thomas Robbins
 

Similar to ASP.NET - Building Web Application..in the right way! (20)

Using MVC with Kentico 8
Using MVC with Kentico 8Using MVC with Kentico 8
Using MVC with Kentico 8
 
Day7
Day7Day7
Day7
 
Mvc
MvcMvc
Mvc
 
Asp.net With mvc handson
Asp.net With mvc handsonAsp.net With mvc handson
Asp.net With mvc handson
 
Asp 1-mvc introduction
Asp 1-mvc introductionAsp 1-mvc introduction
Asp 1-mvc introduction
 
MVC & SQL_In_1_Hour
MVC & SQL_In_1_HourMVC & SQL_In_1_Hour
MVC & SQL_In_1_Hour
 
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
 
ASP.NET MVC_Routing_Authentication_Aurhorization.pdf
ASP.NET MVC_Routing_Authentication_Aurhorization.pdfASP.NET MVC_Routing_Authentication_Aurhorization.pdf
ASP.NET MVC_Routing_Authentication_Aurhorization.pdf
 
ASP.NET MVC 2.0
ASP.NET MVC 2.0ASP.NET MVC 2.0
ASP.NET MVC 2.0
 
Web api
Web apiWeb api
Web api
 
Introduction to ASP.NET MVC
Introduction to ASP.NET MVC Introduction to ASP.NET MVC
Introduction to ASP.NET MVC
 
Simple mvc4 prepared by gigin krishnan
Simple mvc4 prepared by gigin krishnanSimple mvc4 prepared by gigin krishnan
Simple mvc4 prepared by gigin krishnan
 
SoftServe - "ASP.NET MVC як наступний крок у розвитку технології розробки Web...
SoftServe - "ASP.NET MVC як наступний крок у розвитку технології розробки Web...SoftServe - "ASP.NET MVC як наступний крок у розвитку технології розробки Web...
SoftServe - "ASP.NET MVC як наступний крок у розвитку технології розробки Web...
 
ASP.NET MVC introduction
ASP.NET MVC introductionASP.NET MVC introduction
ASP.NET MVC introduction
 
ASP.NET MVC 5 - EF 6 - VS2015
ASP.NET MVC 5 - EF 6 - VS2015ASP.NET MVC 5 - EF 6 - VS2015
ASP.NET MVC 5 - EF 6 - VS2015
 
(ATS6-DEV03) Building an Enterprise Web Solution with AEP
(ATS6-DEV03) Building an Enterprise Web Solution with AEP(ATS6-DEV03) Building an Enterprise Web Solution with AEP
(ATS6-DEV03) Building an Enterprise Web Solution with AEP
 
Sitecore MVC: What it is and why it's important
Sitecore MVC: What it is and why it's importantSitecore MVC: What it is and why it's important
Sitecore MVC: What it is and why it's important
 
Web Development using ASP.NET MVC at HEC
Web Development using ASP.NET MVC at HECWeb Development using ASP.NET MVC at HEC
Web Development using ASP.NET MVC at HEC
 
Getting started with MVC 5 and Visual Studio 2013
Getting started with MVC 5 and Visual Studio 2013Getting started with MVC 5 and Visual Studio 2013
Getting started with MVC 5 and Visual Studio 2013
 
MVC 4
MVC 4MVC 4
MVC 4
 

Recently uploaded

Forklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella PartsForklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella Parts
Intella Parts
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
gdsczhcet
 
road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
VENKATESHvenky89705
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
R&R Consult
 
DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
FluxPrime1
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
Massimo Talia
 
CME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional ElectiveCME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional Elective
karthi keyan
 
ethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.pptethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.ppt
Jayaprasanna4
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
obonagu
 
Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.
PrashantGoswami42
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
bakpo1
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
TeeVichai
 
Event Management System Vb Net Project Report.pdf
Event Management System Vb Net  Project Report.pdfEvent Management System Vb Net  Project Report.pdf
Event Management System Vb Net Project Report.pdf
Kamal Acharya
 
Courier management system project report.pdf
Courier management system project report.pdfCourier management system project report.pdf
Courier management system project report.pdf
Kamal Acharya
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
gerogepatton
 
HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
Robbie Edward Sayers
 
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
H.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdfH.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdf
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
MLILAB
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
AhmedHussein950959
 
addressing modes in computer architecture
addressing modes  in computer architectureaddressing modes  in computer architecture
addressing modes in computer architecture
ShahidSultan24
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Sreedhar Chowdam
 

Recently uploaded (20)

Forklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella PartsForklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella Parts
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
 
road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
 
DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
 
CME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional ElectiveCME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional Elective
 
ethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.pptethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.ppt
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
 
Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
 
Event Management System Vb Net Project Report.pdf
Event Management System Vb Net  Project Report.pdfEvent Management System Vb Net  Project Report.pdf
Event Management System Vb Net Project Report.pdf
 
Courier management system project report.pdf
Courier management system project report.pdfCourier management system project report.pdf
Courier management system project report.pdf
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
 
HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
 
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
H.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdfH.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdf
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
 
addressing modes in computer architecture
addressing modes  in computer architectureaddressing modes  in computer architecture
addressing modes in computer architecture
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
 

ASP.NET - Building Web Application..in the right way!

  • 1. ASP.NET: Building Web Application… in the right way
  • 2. ASP.NET a brief history • 2001 – first release • 2009 – ASP.NET MVC • 2012 – ASP.NET Web API • 2013 – OWIN and SignalR • 2015 – ASP.NET 5 (RC1)
  • 4. MVC web style Webpageinteracts with Controller Model View selects a passes a model to acts on gets data fromproduces invokes
  • 5. ASP.NET MVC • A new presentation option for ASP.NET • Simpler way to program ASP.NET • Easily testable and TDD friendly • More control over your <html/> • More control over your URLs • Supports existing ASP.NET features • Removes: viewstate and postback needs
  • 6. Routing Webpageinteracts with Controller Model View selects a passes a model to acts on gets data fromproduces invokes
  • 7. Routing - example public class OrdersController : Controller { public ActionResult Index() { } public ActionResult Details(int id) { } } http://www.yoursite.com/Orders/Details/1
  • 8. Routing - example http://www.yoursite.com/Orders/Details/1 public class OrdersController : Controller { public ActionResult Index() { } public ActionResult Details(int id) { } }
  • 9. Routing - example http://www.yoursite.com/Orders/Details/1 public class OrdersController : Controller { public ActionResult Index() { } public ActionResult Details(int id) { } }
  • 10. Routing – configuration public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( name: "Default", url: "{controller}/{action}/{id}", defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }); }
  • 11. Routing – configuration routes.MapMvcAttributeRoutes(); // public class OrdersController : Controller { [Route("Orders/{id}/Items")] public ActionResult OrderItems(int id) { } } http://www.yoursite.com/Orders/1/Items
  • 12. Controller Webpageinteracts with Controller Model View selects a passes a model to acts on gets data fromproduces invokes
  • 13. Controller public class OrdersController : Controller { public ActionResult Details(int? id) { Order order = db.Orders.Find(id); if (order == null) return HttpNotFound(); return View(order); } } View("MyWonderfulOrderView", order);
  • 14. Controller – routing and HTTP methods public class OrdersController : Controller { // GET: Orders/Edit/5 public ActionResult Edit(int? id) { } // POST: Orders/Edit/5 [HttpPost] public ActionResult Edit(Order order) { } }
  • 15. Model Webpageinteracts with Controller Model View selects a passes a model to acts on gets data fromproduces invokes
  • 16. Model • View Model or Business Model • Validation attributes, for example: • Required • EmailAddress • StringLength • View-related attributes, e.g. Display public class LoginViewModel { [Required] [Display(Name = "Email address")] [EmailAddress] public string Email { get; set; } [Required] [DataType(DataType.Password)] [Display(Name = "Password")] public string Password { get; set; } [Display(Name = "Remember me")] public bool RememberMe { get; set; } }
  • 17. View Webpageinteracts with Controller Model View selects a passes a model to acts on gets data fromproduces invokes
  • 18. View • Related to controllers/actions by naming convetion • Several View Engine. Standard: Razor, WebFormViewEngine • Support layouts and partial views • Can use strongly-typed model (e.g. Order) or dynamic one (ViewBag) • @Html helper methods (e.g. @Html.TextBoxFor) • @Html methods can be extended
  • 19. ActionResult • ActionResult is the base class for action’s return types • Available results: • ViewResult - Renders a specifed view to the response stream • RedirectResult - Performs an HTTP redirection to a specifed URL • RedirectToRouteResult - Performs an HTTP redirection to a URL that is determined by the routing engine, based on given route data • JsonResult - Serializes a given ViewData object to JSON format • ContentResult - Writes content to the response stream without requiring a view • FileContentResult - Returns a file to the client • and more
  • 20. Model binder • Transform values from client to .NET class instances or primitive types • Retrieves values from HTML form variables, POSTed variables, query string and routing parameters • DefaultModelBinder is the default binder • Binding can be customized, for specific types at application level or at action’s parameter level
  • 21. Filters • Enable Aspect Oriented Programming (AOP) • Different types for different needs: • Authorization filters – IAuthorizationFilter • Action filters – IActionFilter • Result filters – IResultFilter • Exception filters – IExceptionFilter • Filters can be applied to a single action or a whole controller
  • 23. ASP.NET Web API • Formerly part of WCF framework • 2012 – First release • 2013 – Release of Web API 2 • First class framework for HTTP-based services • Foundamental for creating RESTful services • Self-hosted • Different stacks, same concepts – System.Web.Mvc  System.Web.Http
  • 24. ASP.NET Web API cf. MVC • Similar route patterns declarations • Request/method name matching by HTTP verbs config.MapHttpAttributeRoutes(); config.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional }
  • 25. ASP.NET Web API cf. MVC GET http://www.yoursite.com/api/Orders/5 public class OrdersController : ApiController { IQueryable<Order> GetOrders() { … } IHttpActionResult GetOrder(int id) { … } IHttpActionResult PutOrder(int id, Order order) { … } IHttpActionResult PostOrder(Order order) { … } IHttpActionResult DeleteOrder(int id) { … } }
  • 26. ASP.NET Web API cf. MVC • No views or ActionResult just data or IHttpActionResult • Data are serialized in JSON or other format (e.g. XML) • Controllers inherit from ApiController • No more HttpContext.Current • View filters
  • 27. ASP.NET Web API - OData “An open protocol to allow the creation and consumption of queryable and interoperable RESTful APIs in a simple and standard way” EnableQueryAttribute Implements out of the box most of the OData query system: filters, pagination, projection, etc.
  • 28. Let’s go to code Let’s go to code
  • 31. ASP.NET 5 – .NET Core • Totally modular • Faster development cycle • Seamless transition from on-premises to cloud • Choose your editor and tools • Open-source • Cross-platform • Fast
  • 32. ASP.NET 5 cf. ASP.NET 4.X • No more Web Forms and Web API only MVC • One ring stack to rule them all, i.e. no more double coding • Tag helpers – cleaner HTML views • Project and configuration files in JSON • Server side and client side packages completelly decoupled • much more 
  • 33. thank you for your attention stay tuned for next workshops Andrea Vallotti, ph.D andrea.vallotti@commitsoftware.it

Editor's Notes

  1. 1970s – First «implemetation» 1988 – Described as a pattern several interpretations mainly used in GUI clear division between domain objects that model our perception of the real world, and presentation objects that are the GUI elements we see on the screen one model – multiple views (even command line)
  2. Given an URL, the routing engine is in charge of: invoking the correct controller and method (called action); parsing the parameters contained in it.
  3. By naming convetion routing engine will look for a controller (i.e. a class) named OrdersController; Then it will look for an action (i.e. a method) named Details; Routing engine will also try to parse the URL looking for parameter which should be passed to
  4. By naming convetion routing engine will look for a controller (i.e. a class) named OrdersController; Then it will look for an action (i.e. a method) named Details; Routing engine will also try to parse the URL looking for parameter which should be passed to
  5. By naming convetion routing engine will look for a controller (i.e. a class) named OrdersController; Then it will look for an action (i.e. a method) named Details; Routing engine will also try to parse the URL looking for parameter which should be passed to
  6. Standard way of defining routing convention/pattern; Several definitions can be added; Priority based on order; Segment defaults or optional.
  7. Highly customizable Integrated with the "standard approach";
  8. What is a controller: it is a class which derives from Controller class; it exposes public methods which return ActionResult or subclasses of the latter (see in detail later); these methods are called actions; Inside the action usually: it gets a model and acts on it; then select a View (by default the view has the same name of the action) and pass to it the model Other ways to pass data to the View: ViewBag: dynamic, property of the controller Stateless As a rule of thumb actions name must be different even if signatures differ otherwise routing is not able to choose the correct method for a given URL
  9. You can have more more methods with the same name by specifing the HTTP method: AcceptVerbsAttribute HttpDeleteAttribute HttpGetAttribute HttpHeadAttribute HttpOptionsAttribute HttpPatchAttribute HttpPostAttribute HttpPutAttribute
  10. The Model of MVC is intended to be a "View Model" (example default UserLoginModel) However also the Business Model can be used You can use validation attribute to let MVC validate the user input
  11. The Model of MVC is intended to be a "View Model" (example default LoginViewModel) However also the Business Model can be used You can use validation attribute to let MVC validate the user input You can also use attribute to help rendering the view System.ComponentModel.DataAnnotations
  12. Helper, Bundle, etc.
  13. By default all the views are placed in Views/<controller name>/<action name>.cshtml Each project can use its preferred View Engine There are also third-party View Engine which allow to use RoR or Django syntax Layouts are like master pages in old ASP.NET Different layouts can be used for different sections of the application (using Layout property) Strongly-typed using @model directive, dynamic using ViewBag ViewBag can be used by the View (even in strongly-typed) to pass information to the layout and partial views Html helper methods can be used to render standard html elements Helper, Bundle, etc.
  14. Usually action’s return type is ActionResult but you can be more specific using a derived class
  15. DefaultModelBinder creates an empty instance and fills it with values received from client The default binder can be changed using ModelBinders.Binders.DefaultBinder We will see a customization example during the demo
  16. Filters are executed in the order listed Authorization filters are used to implement authentication and authorization for controller actions You can use an action filter, for instance, to modify the view data that a controller action returns. Result filters - you might want to modify a view result right before the view is rendered to the browser. You can use an exception filter to handle errors raised by either your controller actions or controller action results. You also can use exception filters to log errors. System.Web.Mvc.FilterAttribute base class
  17. WCF – Windows Communication Foundation is mainly aimed to SOAP-based services ASP.NET MVC relies on IIS (standard or express) while ASP.NET Web API can be self-hosted
  18. Routing - same declaration style, different classes By default action are matched by HTTP verbs not segment of URL
  19. GET http://www.yoursite.com/api/Orders/5  OrdersController.GetOrder(5)
  20. Data are serialized in JSON or XML based on Accept header of HTTP request Web API was design to work without a web server (i.e. IIS) and with async framework therefore you should never use HttpContext.Current especially when self-hosted Web API is responsible to pass the correct context to each operation Action, Authorization and Exception filters are still available
  21. Basically OData is a way to standardize REST services, e.g. by defining how to filter It is «simply» an action filter which works with an IQueryable
  22. .NET Core 5: is the version of .NET that runs on Mac, Windows and Linux; brings features via packages  framework much smaller; ASP.NET 5 runs both on .NET Framework 4.6 and .NET Core;
  23. Totally modular – cause all the library (such as MVC, file, etc.) have been stripped from the core  you have to download them with NuGet Faster development cycle – simply modify the code and refresh your page, the code will be automatically compiled Seamless transition – the application runs with its own framework and libraries therefore you do not need to install «special» stuff on the server Editor and tools – Visual Studio, Visual Studio Code on all platforms but through OmniaSharp also emacs, sublime, etc. are supported. Yeoman generator!!! Cross-platform – Kestrel is a standalone web server based on libuv (the same as Node.JS), Fast  benchmarks show that ASP.NET 5 is faster than Node.JS 
  24. ASP.NET 5  only MVC which contains both old MVC and Web API One stack  one Controller base class, one routing configuration, model binding, etc. All controllers can have actions which return ActionResult or data System.Web.* does not exist anymore we have the package Microsoft.AspNet.Mvc Tag helpers  just like angular directive, allows to write more HTML and take advantage of intellisense for CSS and HTML JSON files  no more XML, JSON is easier to understand and widely used Server/client side  NuGet for the server and Bower for the client
  25. Vi rigrazio per l’attenzione e spero di essere riuscito a sintetizzare un argomento che richiede molti approfondimenti. Qui trovate i miei contatti e sono a disposizione al desk per un veloce incontro per rispondere a tutte le vostre domande. Grazie ancora e buon forum a tutti.