SlideShare a Scribd company logo
ASP.NET MVC
@{ Introduction & Guidelines }
Speaker Introduction
Dev Raj Gautam
Application & Database Specialist
Nutrition Innovation Lab: Nepal
Active Contributor @ASP.NET Community
http://blogs.devgautam.com.np/
Have been in industry since 2009. Worked with government, local
companies, outsourcing companies and Ingo's .
©Dev Raj Gautam, 2015, http://blogs.devgautam.com.np/
Agenda
• Introduction to MVC
• What Does MVC Offer?
• Demo
• Routing & Web API.
• Web Forms Or MVC?
©Dev Raj Gautam, 2015, http://blogs.devgautam.com.np/
Introduction
©Dev Raj Gautam, 2015, http://blogs.devgautam.com.np/
Asp.Net MVC1
Released on Mar 13, 2009
ASP.NET Web Forms is not part of ASP.NET 5
©Dev Raj Gautam, 2015, http://blogs.devgautam.com.np/
I was already there from
70’s
MVC
©Dev Raj Gautam, 2015, http://blogs.devgautam.com.np/
MVC
• Stands for Model View Controller. Common design pattern for
• MVC is a software architectural pattern that follows the 'Separation of
Concerns' principle. This principle divides an application into three
interconnected parts as Model, View and Controller each with very
specific set of responsibilities. The goal of this pattern is that each of
these parts can be developed and tested in relative isolation and then
combine together to create a very robust application.
©Dev Raj Gautam, 2015, http://blogs.devgautam.com.np/
Model-View-Controller
• Model: These are the classes that contain data. They can practically
be any class that can be instantiated and can provide some data.
These can be entity framework generated entities, collection, generics
or even generic collections too.
• Controllers: These are the classes that will be invoked on user
requests. The main tasks of these are to generate the model class
object, pass them to some view and tell the view to generate markup
and render it on user browser.
• Views: The part of the application that handles user interaction.
Typically controllers read data from a view, control user input, and
send input data to the model.
©Dev Raj Gautam, 2015, http://blogs.devgautam.com.np/
How MVC Works?
©Dev Raj Gautam, 2015, http://blogs.devgautam.com.np/
What does MVC Offer?
©Dev Raj Gautam, 2015, http://blogs.devgautam.com.np/
Performance
• ASP.NET MVC don’t have support for view state, so there will not be
any automatic state management which reduces the page size and so
gain the performance.
ViewState
©Dev Raj Gautam, 2015, http://blogs.devgautam.com.np/
Separation Of Concern
• When we talk about Views and Controllers, their ownership itself
explains separation.The Views are just the presentation form of an
application, it does not need to know specifically about the requests
coming from the Controller. The Model is independent of Views and
Controllers, it only holds business entities that can be ed to any View
by the Controller as per the needs for exposing them to the end user.
The Controller is independent of Views and Models, its sole purpose
is to handle requests and them on as per the routes defined and as
per the needs of the rendering Views. Thus our business entities
(Model), business logic (Controllers) and presentation logic (Views) lie
in logical/physical layers independent of each other.
©Dev Raj Gautam, 2015, http://blogs.devgautam.com.np/
Existing ASP.NET Features
• ASP.NET MVC framework is built on top of matured ASP.NET
framework and thus provides developer to use many good features
such as forms authentication, windows authentication, caching,
session and profile state management etc.
©Dev Raj Gautam, 2015, http://blogs.devgautam.com.np/
Parallel Development
• In ASP.NET MVC layers are loosely coupled with each other, so one
developer can work on Controller ,at the same time other on View
and third developer on Model. This is called parallel development.
©Dev Raj Gautam, 2015, http://blogs.devgautam.com.np/
Full Control Over <HTML></HTML>
• ASP.NET MVC doesn’t support server controls, only option available is
using html input controls, so we will be sure about final html
rendered at the end. We will also be aware about 'id' of every
element. And so integration of ASP.NET MVC application with third
party JavaScript libraries like jQuery becomes easy.
©Dev Raj Gautam, 2015, http://blogs.devgautam.com.np/
Testing
• Asp.Net webforms is dependent on HttpContext.Current, our pages as
part of the HttpApplication executing the request Which makes
• These are all easily mockable!
• HttpContextBase, HttpResponseBase, HttpRequestBase
[TestMethod]
public void ShowPostsDisplayPostView()
{
BlogController controller = new BlogController(…);
var result = controller.ShowPost(2) as ViewResult;
Assert.IsNotNull(result);
Assert.AreEqual(result.ViewData["Message"], "Hello");
}
©Dev Raj Gautam, 2015, http://blogs.devgautam.com.np/
Testing
• [TestMethod]
• public void TestInvalidCredentials()
• {
• LoginController controller = new LoginController();
• var mock = new Mock<System.Web.Security.MembershipProvider>();
• mock.Expect(m => m.ValidateUser("", "")).Returns(false);
• controller.MembershipProviderInstance = mock.Object;
• var result = controller.Authenticate("", "") as ViewResult;
• Assert.IsNotNull(result);
• Assert.AreEqual(result.ViewName, "Index");
• Assert.AreEqual(controller.ViewData["ErrorMessage"], "Invalid credentials!
Please verify your username and password.");
• }
©Dev Raj Gautam, 2015, http://blogs.devgautam.com.np/
Clean URLS
• ASP.NET MVC is so tightly integrated with the ASP.NET Routing engine,
it is simple to take control over the URLs that your application
exposes.
Would you use:
/Products.aspx?CategoryID={3F2504E0-4F89-11D3-9A0C-0305E82C3301}
Or:
/Products/Books
SEO
©Dev Raj Gautam, 2015, http://blogs.devgautam.com.np/
Demo
©Dev Raj Gautam, 2015, http://blogs.devgautam.com.np/
What’s In Demo
• Understanding the MVC Project Structure
• Understanding and Modifying the Layout and Templeates
• CRUD with project template
• CRUD DIY with code
• Basics of Routing
• Basics of Web API
©Dev Raj Gautam, 2015, http://blogs.devgautam.com.np/
Routing & Web API
©Dev Raj Gautam, 2015, http://blogs.devgautam.com.np/
Routing
• Routing maps request URL to a specific controller action using a
Routing Table
• Routing Engine uses routing rules that are defined in Global.asax file
in order to parse the URL and find out the path of corresponding
controller.
©Dev Raj Gautam, 2015, http://blogs.devgautam.com.np/
WEB API
• Restful framework for Building HTTP Based services
• What is Rest? “Rest is an architectural style that abstracts the
architectural elements within a distributed hypermedia system”
• https://api.twitter.com/1.1/statuses/retweets/2.json
• Web API is not MVC
©Dev Raj Gautam, 2015, http://blogs.devgautam.com.np/
What In the
World Is WCF
Then? HUH!!!!
©Dev Raj Gautam, 2015, http://blogs.devgautam.com.np/
Use When?
Web API
• Only working with HTTP
• Want RESTful endpoints
• Don’t need multiple protocols
• Don’t expose SOAP endpoints
• Want Simple Configuration
WCF
• Needs to support multiple
protocols
• Need to expose SOAP endpoints
• Need Complex Configuration
• Need RPC Style Requests
©Dev Raj Gautam, 2015, http://blogs.devgautam.com.np/
Web Forms or MVC?
©Dev Raj Gautam, 2015, http://blogs.devgautam.com.np/
Web Forms or MVC?
Web Froms
• Winforms-alike event model
• Familiar controls & Rich
• Familiar = rapid application
development
• Functionality per page
• Uses viewstate for state
management
• Less control over rendered HTML
• Event Driven Programming
• Oh wow! I can turn of or control
View State Size.
MVC
• Less complex: separation of
concerns
• Easier parallel development
• TDD support
• No viewstate, …
• Full control over behavior and
HTML
• Extensive Javascript
• Makes you think
©Dev Raj Gautam, 2015, http://blogs.devgautam.com.np/
Web Forms or MVC?
©Dev Raj Gautam, 2015, http://blogs.devgautam.com.np/
Web Forms or MVC?
• Mixing the Technologies can also do wonders for some solutions
MVC Web Forms
©Dev Raj Gautam, 2015, http://blogs.devgautam.com.np/
Verdict?
• Please decide on your own on the basis of previous slides.
©Dev Raj Gautam, 2015, http://blogs.devgautam.com.np/
Thank You
©Dev Raj Gautam, 2015, http://blogs.devgautam.com.np/

More Related Content

What's hot (20)

PPTX
ASP.NET MVC.
Ni
 
PDF
MVC Seminar Presantation
Abhishek Yadav
 
PPTX
ASP .NET MVC
eldorina
 
PPTX
Asp.net mvc presentation by Nitin Sawant
Nitin S
 
PPT
Asp.net mvc
Naga Harish M
 
PPTX
ASP.NET MVC for Begineers
Shravan Kumar Kasagoni
 
PPT
CTTDNUG ASP.NET MVC
Barry Gervin
 
PDF
ASP.NET MVC 3
Buu Nguyen
 
PPTX
Asp.net MVC training session
Hrichi Mohamed
 
PPT
Silver Light By Nyros Developer
Nyros Technologies
 
PPSX
Asp.net mvc
Er. Kamal Bhusal
 
PPT
MVC(Model View Controller),Web,Enterprise,Mobile
naral
 
PPTX
MVC Framework
Ashton Feller
 
PDF
Model View Controller (MVC)
Javier Antonio Humarán Peñuñuri
 
PDF
MVC architecture
Emily Bauman
 
PPTX
Model view controller (mvc)
M Ahsan Khan
 
PPTX
Mvc pattern and implementation in java fair
Tech_MX
 
PPTX
Mvc fundamental
Nguyễn Thành Phát
 
PPTX
What's new in asp.net mvc 4
Simone Chiaretta
 
ASP.NET MVC.
Ni
 
MVC Seminar Presantation
Abhishek Yadav
 
ASP .NET MVC
eldorina
 
Asp.net mvc presentation by Nitin Sawant
Nitin S
 
Asp.net mvc
Naga Harish M
 
ASP.NET MVC for Begineers
Shravan Kumar Kasagoni
 
CTTDNUG ASP.NET MVC
Barry Gervin
 
ASP.NET MVC 3
Buu Nguyen
 
Asp.net MVC training session
Hrichi Mohamed
 
Silver Light By Nyros Developer
Nyros Technologies
 
Asp.net mvc
Er. Kamal Bhusal
 
MVC(Model View Controller),Web,Enterprise,Mobile
naral
 
MVC Framework
Ashton Feller
 
Model View Controller (MVC)
Javier Antonio Humarán Peñuñuri
 
MVC architecture
Emily Bauman
 
Model view controller (mvc)
M Ahsan Khan
 
Mvc pattern and implementation in java fair
Tech_MX
 
Mvc fundamental
Nguyễn Thành Phát
 
What's new in asp.net mvc 4
Simone Chiaretta
 

Viewers also liked (17)

PPTX
DotNet programming & Practices
Dev Raj Gautam
 
PPT
Why MVC?
Wayne Tun Myint
 
PPTX
Industrial training seminar ppt on asp.net
Pankaj Kushwaha
 
PDF
Double cartridge seal
American Seal and Packing
 
ODP
El sectorterciari pvr
llulsil23
 
PDF
What is Split seals?
American Seal and Packing
 
ODS
Plant climo office(1) (1)
llulsil23
 
PPTX
Pathos presentation
Kassia Waggoner
 
PPTX
Aix admin-course-provider-navi-mumbai
anshkhurana01
 
PPT
Ci powerpoint
tanyacork
 
RTF
What is Spiral Wound Gaskets?
American Seal and Packing
 
PDF
Java j2ee-training-course-navi-mumbai-java-j2ee-course-provider-navi-mumbai
anshkhurana01
 
PDF
Tibco training-course-navi-mumbai-tibco-course-provider-navi-mumbai
anshkhurana01
 
PPT
E&C Вrodaband 2015 Власть перезагрузка создание коммуникациинной платформы дл...
Expert and Consulting (EnC)
 
PPT
05php
anshkhurana01
 
DOCX
sas-course-provider-navi-mumbai-sas-training-navi-mumbai-sas-classes-navi-mumbai
anshkhurana01
 
PPT
Capital steel buildings business opportunities-uk
Rehmat Ullah
 
DotNet programming & Practices
Dev Raj Gautam
 
Why MVC?
Wayne Tun Myint
 
Industrial training seminar ppt on asp.net
Pankaj Kushwaha
 
Double cartridge seal
American Seal and Packing
 
El sectorterciari pvr
llulsil23
 
What is Split seals?
American Seal and Packing
 
Plant climo office(1) (1)
llulsil23
 
Pathos presentation
Kassia Waggoner
 
Aix admin-course-provider-navi-mumbai
anshkhurana01
 
Ci powerpoint
tanyacork
 
What is Spiral Wound Gaskets?
American Seal and Packing
 
Java j2ee-training-course-navi-mumbai-java-j2ee-course-provider-navi-mumbai
anshkhurana01
 
Tibco training-course-navi-mumbai-tibco-course-provider-navi-mumbai
anshkhurana01
 
E&C Вrodaband 2015 Власть перезагрузка создание коммуникациинной платформы дл...
Expert and Consulting (EnC)
 
sas-course-provider-navi-mumbai-sas-training-navi-mumbai-sas-classes-navi-mumbai
anshkhurana01
 
Capital steel buildings business opportunities-uk
Rehmat Ullah
 
Ad

Similar to ASP .NET MVC Introduction & Guidelines (20)

PPTX
SoftServe - "ASP.NET MVC як наступний крок у розвитку технології розробки Web...
SoftServe
 
PDF
Introduction to ASP.NET MVC
Mayank Srivastava
 
PPTX
Intro ASP MVC
KrishnaPPatel
 
PPTX
Which is better asp.net mvc vs asp.net
Concetto Labs
 
PPTX
ASPNet MVC series for beginers part 1
Gaurav Arora
 
PPTX
Asp net mvc series for beginers part 1
Gaurav Arora
 
PPS
Introduction To Mvc
Volkan Uzun
 
PPT
Asp.net,mvc
Prashant Kumar
 
PPTX
Introduction to ASP.Net MVC
Sagar Kamate
 
PDF
Targeting Mobile Platform with MVC 4.0
Mayank Srivastava
 
PPTX
Asp.Net MVC Intro
Stefano Paluello
 
PPTX
ASP.NET Presentation
Rasel Khan
 
PPTX
ASP.net MVC Introduction Wikilogia (nov 2014)
Hatem Hamad
 
PPTX
Technoligent providing custom ASP.NET MVC development services
Aaron Jacobson
 
PPTX
Asp.net With mvc handson
Prashant Kumar
 
PPT
Asp.net mvc
Taranjeet Singh
 
PDF
Aspnetmvc 1
Fajar Baskoro
 
PDF
Asp 1a-aspnetmvc
Fajar Baskoro
 
PPTX
MVC 4
Vasilios Kuznos
 
SoftServe - "ASP.NET MVC як наступний крок у розвитку технології розробки Web...
SoftServe
 
Introduction to ASP.NET MVC
Mayank Srivastava
 
Intro ASP MVC
KrishnaPPatel
 
Which is better asp.net mvc vs asp.net
Concetto Labs
 
ASPNet MVC series for beginers part 1
Gaurav Arora
 
Asp net mvc series for beginers part 1
Gaurav Arora
 
Introduction To Mvc
Volkan Uzun
 
Asp.net,mvc
Prashant Kumar
 
Introduction to ASP.Net MVC
Sagar Kamate
 
Targeting Mobile Platform with MVC 4.0
Mayank Srivastava
 
Asp.Net MVC Intro
Stefano Paluello
 
ASP.NET Presentation
Rasel Khan
 
ASP.net MVC Introduction Wikilogia (nov 2014)
Hatem Hamad
 
Technoligent providing custom ASP.NET MVC development services
Aaron Jacobson
 
Asp.net With mvc handson
Prashant Kumar
 
Asp.net mvc
Taranjeet Singh
 
Aspnetmvc 1
Fajar Baskoro
 
Asp 1a-aspnetmvc
Fajar Baskoro
 
Ad

More from Dev Raj Gautam (8)

PPTX
Protecting PII & AI Workloads in PostgreSQL
Dev Raj Gautam
 
PPTX
RED’S, GREEN’S & BLUE’S OF PROJECT/PRODUCT MANAGEMENT
Dev Raj Gautam
 
PPTX
Making machinelearningeasier
Dev Raj Gautam
 
PPTX
Recommender System Using AZURE ML
Dev Raj Gautam
 
PPTX
From c# Into Machine Learning
Dev Raj Gautam
 
PPTX
Machine Learning With ML.NET
Dev Raj Gautam
 
PPTX
Intelligent bots
Dev Raj Gautam
 
PPTX
SOA & WCF
Dev Raj Gautam
 
Protecting PII & AI Workloads in PostgreSQL
Dev Raj Gautam
 
RED’S, GREEN’S & BLUE’S OF PROJECT/PRODUCT MANAGEMENT
Dev Raj Gautam
 
Making machinelearningeasier
Dev Raj Gautam
 
Recommender System Using AZURE ML
Dev Raj Gautam
 
From c# Into Machine Learning
Dev Raj Gautam
 
Machine Learning With ML.NET
Dev Raj Gautam
 
Intelligent bots
Dev Raj Gautam
 
SOA & WCF
Dev Raj Gautam
 

Recently uploaded (20)

PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PDF
July Patch Tuesday
Ivanti
 
DOCX
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
PDF
Advancing WebDriver BiDi support in WebKit
Igalia
 
PDF
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PDF
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PDF
What Makes Contify’s News API Stand Out: Key Features at a Glance
Contify
 
PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
July Patch Tuesday
Ivanti
 
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
Advancing WebDriver BiDi support in WebKit
Igalia
 
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
What Makes Contify’s News API Stand Out: Key Features at a Glance
Contify
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 

ASP .NET MVC Introduction & Guidelines

  • 2. Speaker Introduction Dev Raj Gautam Application & Database Specialist Nutrition Innovation Lab: Nepal Active Contributor @ASP.NET Community http://blogs.devgautam.com.np/ Have been in industry since 2009. Worked with government, local companies, outsourcing companies and Ingo's . ©Dev Raj Gautam, 2015, http://blogs.devgautam.com.np/
  • 3. Agenda • Introduction to MVC • What Does MVC Offer? • Demo • Routing & Web API. • Web Forms Or MVC? ©Dev Raj Gautam, 2015, http://blogs.devgautam.com.np/
  • 4. Introduction ©Dev Raj Gautam, 2015, http://blogs.devgautam.com.np/
  • 5. Asp.Net MVC1 Released on Mar 13, 2009 ASP.NET Web Forms is not part of ASP.NET 5 ©Dev Raj Gautam, 2015, http://blogs.devgautam.com.np/
  • 6. I was already there from 70’s MVC ©Dev Raj Gautam, 2015, http://blogs.devgautam.com.np/
  • 7. MVC • Stands for Model View Controller. Common design pattern for • MVC is a software architectural pattern that follows the 'Separation of Concerns' principle. This principle divides an application into three interconnected parts as Model, View and Controller each with very specific set of responsibilities. The goal of this pattern is that each of these parts can be developed and tested in relative isolation and then combine together to create a very robust application. ©Dev Raj Gautam, 2015, http://blogs.devgautam.com.np/
  • 8. Model-View-Controller • Model: These are the classes that contain data. They can practically be any class that can be instantiated and can provide some data. These can be entity framework generated entities, collection, generics or even generic collections too. • Controllers: These are the classes that will be invoked on user requests. The main tasks of these are to generate the model class object, pass them to some view and tell the view to generate markup and render it on user browser. • Views: The part of the application that handles user interaction. Typically controllers read data from a view, control user input, and send input data to the model. ©Dev Raj Gautam, 2015, http://blogs.devgautam.com.np/
  • 9. How MVC Works? ©Dev Raj Gautam, 2015, http://blogs.devgautam.com.np/
  • 10. What does MVC Offer? ©Dev Raj Gautam, 2015, http://blogs.devgautam.com.np/
  • 11. Performance • ASP.NET MVC don’t have support for view state, so there will not be any automatic state management which reduces the page size and so gain the performance. ViewState ©Dev Raj Gautam, 2015, http://blogs.devgautam.com.np/
  • 12. Separation Of Concern • When we talk about Views and Controllers, their ownership itself explains separation.The Views are just the presentation form of an application, it does not need to know specifically about the requests coming from the Controller. The Model is independent of Views and Controllers, it only holds business entities that can be ed to any View by the Controller as per the needs for exposing them to the end user. The Controller is independent of Views and Models, its sole purpose is to handle requests and them on as per the routes defined and as per the needs of the rendering Views. Thus our business entities (Model), business logic (Controllers) and presentation logic (Views) lie in logical/physical layers independent of each other. ©Dev Raj Gautam, 2015, http://blogs.devgautam.com.np/
  • 13. Existing ASP.NET Features • ASP.NET MVC framework is built on top of matured ASP.NET framework and thus provides developer to use many good features such as forms authentication, windows authentication, caching, session and profile state management etc. ©Dev Raj Gautam, 2015, http://blogs.devgautam.com.np/
  • 14. Parallel Development • In ASP.NET MVC layers are loosely coupled with each other, so one developer can work on Controller ,at the same time other on View and third developer on Model. This is called parallel development. ©Dev Raj Gautam, 2015, http://blogs.devgautam.com.np/
  • 15. Full Control Over <HTML></HTML> • ASP.NET MVC doesn’t support server controls, only option available is using html input controls, so we will be sure about final html rendered at the end. We will also be aware about 'id' of every element. And so integration of ASP.NET MVC application with third party JavaScript libraries like jQuery becomes easy. ©Dev Raj Gautam, 2015, http://blogs.devgautam.com.np/
  • 16. Testing • Asp.Net webforms is dependent on HttpContext.Current, our pages as part of the HttpApplication executing the request Which makes • These are all easily mockable! • HttpContextBase, HttpResponseBase, HttpRequestBase [TestMethod] public void ShowPostsDisplayPostView() { BlogController controller = new BlogController(…); var result = controller.ShowPost(2) as ViewResult; Assert.IsNotNull(result); Assert.AreEqual(result.ViewData["Message"], "Hello"); } ©Dev Raj Gautam, 2015, http://blogs.devgautam.com.np/
  • 17. Testing • [TestMethod] • public void TestInvalidCredentials() • { • LoginController controller = new LoginController(); • var mock = new Mock<System.Web.Security.MembershipProvider>(); • mock.Expect(m => m.ValidateUser("", "")).Returns(false); • controller.MembershipProviderInstance = mock.Object; • var result = controller.Authenticate("", "") as ViewResult; • Assert.IsNotNull(result); • Assert.AreEqual(result.ViewName, "Index"); • Assert.AreEqual(controller.ViewData["ErrorMessage"], "Invalid credentials! Please verify your username and password."); • } ©Dev Raj Gautam, 2015, http://blogs.devgautam.com.np/
  • 18. Clean URLS • ASP.NET MVC is so tightly integrated with the ASP.NET Routing engine, it is simple to take control over the URLs that your application exposes. Would you use: /Products.aspx?CategoryID={3F2504E0-4F89-11D3-9A0C-0305E82C3301} Or: /Products/Books SEO ©Dev Raj Gautam, 2015, http://blogs.devgautam.com.np/
  • 19. Demo ©Dev Raj Gautam, 2015, http://blogs.devgautam.com.np/
  • 20. What’s In Demo • Understanding the MVC Project Structure • Understanding and Modifying the Layout and Templeates • CRUD with project template • CRUD DIY with code • Basics of Routing • Basics of Web API ©Dev Raj Gautam, 2015, http://blogs.devgautam.com.np/
  • 21. Routing & Web API ©Dev Raj Gautam, 2015, http://blogs.devgautam.com.np/
  • 22. Routing • Routing maps request URL to a specific controller action using a Routing Table • Routing Engine uses routing rules that are defined in Global.asax file in order to parse the URL and find out the path of corresponding controller. ©Dev Raj Gautam, 2015, http://blogs.devgautam.com.np/
  • 23. WEB API • Restful framework for Building HTTP Based services • What is Rest? “Rest is an architectural style that abstracts the architectural elements within a distributed hypermedia system” • https://api.twitter.com/1.1/statuses/retweets/2.json • Web API is not MVC ©Dev Raj Gautam, 2015, http://blogs.devgautam.com.np/
  • 24. What In the World Is WCF Then? HUH!!!! ©Dev Raj Gautam, 2015, http://blogs.devgautam.com.np/
  • 25. Use When? Web API • Only working with HTTP • Want RESTful endpoints • Don’t need multiple protocols • Don’t expose SOAP endpoints • Want Simple Configuration WCF • Needs to support multiple protocols • Need to expose SOAP endpoints • Need Complex Configuration • Need RPC Style Requests ©Dev Raj Gautam, 2015, http://blogs.devgautam.com.np/
  • 26. Web Forms or MVC? ©Dev Raj Gautam, 2015, http://blogs.devgautam.com.np/
  • 27. Web Forms or MVC? Web Froms • Winforms-alike event model • Familiar controls & Rich • Familiar = rapid application development • Functionality per page • Uses viewstate for state management • Less control over rendered HTML • Event Driven Programming • Oh wow! I can turn of or control View State Size. MVC • Less complex: separation of concerns • Easier parallel development • TDD support • No viewstate, … • Full control over behavior and HTML • Extensive Javascript • Makes you think ©Dev Raj Gautam, 2015, http://blogs.devgautam.com.np/
  • 28. Web Forms or MVC? ©Dev Raj Gautam, 2015, http://blogs.devgautam.com.np/
  • 29. Web Forms or MVC? • Mixing the Technologies can also do wonders for some solutions MVC Web Forms ©Dev Raj Gautam, 2015, http://blogs.devgautam.com.np/
  • 30. Verdict? • Please decide on your own on the basis of previous slides. ©Dev Raj Gautam, 2015, http://blogs.devgautam.com.np/
  • 31. Thank You ©Dev Raj Gautam, 2015, http://blogs.devgautam.com.np/

Editor's Notes

  • #17: In most cases, in order to get the page to execute correctly, you need to execute it in a real HttpContext. Since many of the properties of HttpContext are not settable (like Request and Response), it is extremely difficult to construct fake requests to send to your page objects. This makes unit testing webforms pages a nightmare, since it couples all your tests to needing all kinds of context setup.
  • #23: routes are configured on application start by calling a staticmethod "RegisterRoutes" in RouteConfig class. We can find RouteConfig.cs file under App_Start folder in ASP.NET MVC 5 application. 
  • #29: Rapid application development  go with asp.net Web Forms, Unit Testing - If automatic unit testing is most important factor for you MVC  Does your team have experience on ASP or non-Microsoft technologies such as android, ios, JSP, ROR, PHP? Is JavaScript going to be used extensively? Looking for good performance? Planning to reuse the same input logic?
  • #30: How to Use it? Add a reference to three core librares System.Web.Routing,System.Web.Abstractions, System.Web.MVC Add the controllers and view directories Update the Web.Config to load the three assemblies at runtime and registering the URLRewriting Module Registering the Routes in Global Asax Model.