SlideShare a Scribd company logo
S.No ASP.NET Web API

ASP.NET MVC

1

Purpose of ASP.NET MVC:
To create web applications that returns both
views and data.

Purpose of ASP.NET Web API:
To create full blown HTTP services with
easy and simple way that returns only data
not view.
i.e., ASP.NET Web API is focused on
making output of raw data easy.

i.e., ASP.NET MVC is focused on making
output of HTML easy.

In the WebForms world, ASP.NET MVC
In the WebForms world, ASP.NET Web API would be equivalent to .aspx pages.
would be equivalent to .asmx pages.
2

Default Assumption for ASP.NET Web
API:
ASP.NET Web API by default assumes that
primitive type comes from query string and
non-primitive types comes from the form. It
also assumes that we would only want to
read the form body once, without caching,
to have lower memory usage and better
performance.

Default Assumption for ASP.NET MVC:
ASP.NET MVC by default assumes user
submitted data can come from multiple
sources, be it in the query string or in the
form.

3

Whether it is possible to make ASP.NET
Web API output HTML ?
Yes

Whether it is possible to make ASP.NET
MVC output raw data ?
Yes

But, we need to do some additional work as But, we need to do some additional work as
provided below,
provided below,
Making additional classes to handle
text/html during content negotiation in
ASP.NET Web API.

Adding logic to handle OData queries in
ASP.NET MVC.

4

GET AJAX Request in ASP.NET Web
API:
ASP.NET Web API allows GET AJAX
request by default.

GET AJAX Request in ASP.NET MVC:
GET AJAX request is blocked by ASP.NET
MVC's JsonResult by default to prevent
CSRF.

5

Whether RESTful services can be created
with ASP.NET Web API ?
ASP.NET Web API helps the creation of
RESTful services over the .Net Framework.

Whether RESTful services can be created
with ASP.NET MVC ?
With ASP.NET MVC, we cannot able to
create RESTful services.

6

Return format of data:
ASP.NET Web API returns the data in
various formats, such as JSON, XML and
other format based on the accept header of
the request.

Return format of data:
ASP.NET MVC returns the data in the JSON
format by using JSONResult.

7

Request Mapping:
Request Mapping:
In ASP.NET Web API the request are
In ASP.NET MVC the request is mapped to
mapped to the actions based on HTTP verbs. actions name.

8

Where we can see the features such as:
model binding, filters, routing etc., in

Where we can see the features such as:
model binding, filters, routing etc., in
ASP.NET Web API ?
System.Web.Http
9

ASP.NET MVC?
System.Web.Mvc

Whether content negotiation and self
hosting features are supported ?
ASP.NET Web API supports content
negotiation, self hosting.

Whether content negotiation and self
hosting features are supported ?
ASP.NET MVC does not support content
negotiation and self hosting features.

Content Negatiotion – It is about deciding
the best response format data that could be
acceptable by the client. it could be
JSON,XML,ATOM or other formatted data
10

How routing is defined in ASP.NET Web
API?
Routing is defined by webapiconfig class
i.e., using MapHttpRoute method.

How routing is defined in ASP.NET MVC?
Routing is defined by routeconfig class i.e.,
using MapRoute method .

Unlike MVC, Routing API here does not
use any reference to MVC .
11

When to use ASP.NET Web API?
Web API is more capable of supporting
many different clients,namely, WPF Client,
iPhone, Android, iPad, Windows Phone 7,
Windows Phone 8, Web Browsers: IE,
Firefox, Chrome etc., then ASP.NET Web
API is likely going to be a better choice.

When to use ASP.NET MVC?
Asp.NET MVC is optimized for having a web
browser as a client.
If our only client is a web browser, then MVC
is likely going to be a better choice.

Note:
1.We can mix Web API and MVC controller in a single project to handle advanced AJAX requests
which may return data in JSON, XML or any others format and building a full blown HTTP service.
Typically, this will be called Web API self hosting.
2.When we have mixed MVC and Web API controller and you want to implement the authorization
then we have to create two filters one for MVC and another for Web API since boths are different.
Reference:
http://onlydifferencefaqs.blogspot.in/2014/02/difference-between-aspnet-web-api-and.html

More Related Content

PPTX
Django PPT.pptx
KhyatiBandi1
Ā 
PPT
Node.js Express Framework
TheCreativedev Blog
Ā 
PPTX
What is an API?
Muhammad Zuhdi
Ā 
PPT
Introduction to the Web API
Brad Genereaux
Ā 
PPTX
Ajax ppt - 32 slides
Smithss25
Ā 
PPTX
Array vs array list
Ravi Shetye
Ā 
PPT
TypeScript Presentation
Patrick John PacaƱa
Ā 
PPT
JSP
vikram singh
Ā 
Django PPT.pptx
KhyatiBandi1
Ā 
Node.js Express Framework
TheCreativedev Blog
Ā 
What is an API?
Muhammad Zuhdi
Ā 
Introduction to the Web API
Brad Genereaux
Ā 
Ajax ppt - 32 slides
Smithss25
Ā 
Array vs array list
Ravi Shetye
Ā 
TypeScript Presentation
Patrick John PacaƱa
Ā 

What's hot (20)

PPTX
Javax.servlet,http packages
vamsi krishna
Ā 
PDF
Code Smells and Its type (With Example)
Anshul Vinayak
Ā 
PDF
Spring Boot Interview Questions | Edureka
Edureka!
Ā 
PPTX
Spring boot Introduction
Jeevesh Pandey
Ā 
PPSX
SOLID Principles and The Clean Architecture
Mohamed Galal
Ā 
PDF
Javascript - Tutorial
adelaticleanu
Ā 
PPTX
Servlets
Geethu Mohan
Ā 
PDF
API Basics
Ritul Chaudhary
Ā 
PDF
Servlet vs Reactive Stacks in 5 Use Cases
VMware Tanzu
Ā 
PPTX
Introduction to REST - API
Chetan Gadodia
Ā 
PPTX
Reactjs workshop
Ahmed rebai
Ā 
PDF
Struts2
Rajiv Gupta
Ā 
PDF
TDC2015: Testes em APIs REST com Rest-Assured
JĆŗlio de Lima
Ā 
PPTX
ASP.NET Core MVC + Web API with Overview
Shahed Chowdhuri
Ā 
PPTX
Android pentesting
Mykhailo Antonishyn
Ā 
PDF
Introduction to API
rajnishjha29
Ā 
PPTX
AngularJS
Maurice De Beijer [MVP]
Ā 
PDF
Postman
Igor Shubovych
Ā 
PDF
Introduction to Hibernate Framework
Mohit Kanwar
Ā 
PPTX
Soap vs rest
Antonio Severien
Ā 
Javax.servlet,http packages
vamsi krishna
Ā 
Code Smells and Its type (With Example)
Anshul Vinayak
Ā 
Spring Boot Interview Questions | Edureka
Edureka!
Ā 
Spring boot Introduction
Jeevesh Pandey
Ā 
SOLID Principles and The Clean Architecture
Mohamed Galal
Ā 
Javascript - Tutorial
adelaticleanu
Ā 
Servlets
Geethu Mohan
Ā 
API Basics
Ritul Chaudhary
Ā 
Servlet vs Reactive Stacks in 5 Use Cases
VMware Tanzu
Ā 
Introduction to REST - API
Chetan Gadodia
Ā 
Reactjs workshop
Ahmed rebai
Ā 
Struts2
Rajiv Gupta
Ā 
TDC2015: Testes em APIs REST com Rest-Assured
JĆŗlio de Lima
Ā 
ASP.NET Core MVC + Web API with Overview
Shahed Chowdhuri
Ā 
Android pentesting
Mykhailo Antonishyn
Ā 
Introduction to API
rajnishjha29
Ā 
Postman
Igor Shubovych
Ā 
Introduction to Hibernate Framework
Mohit Kanwar
Ā 
Soap vs rest
Antonio Severien
Ā 
Ad

Similar to Difference between asp.net web api and asp.net mvc (20)

PDF
ASP.NET Web API Interview Questions By Scholarhat
Scholarhat
Ā 
PPTX
Asp.net web api
Binu Bhasuran
Ā 
PPTX
C# web api
Simplilearn
Ā 
PPTX
Web API or WCF - An Architectural Comparison
Adnan Masood
Ā 
PPTX
ASP.NET Mvc 4 web api
Tiago Knoch
Ā 
PDF
Complete guidance book of Asp.Net Web API
Shabista Imam
Ā 
PDF
Difference between wcf and asp.net web api
Umar Ali
Ā 
PDF
ASP.NET Core 1 for MVC- and WebAPI-Devs
Manfred Steyer
Ā 
PPTX
CodeCamp Iasi 10 March 2012 - Gabriel Enea - ASP.NET Web API
Codecamp Romania
Ā 
PPTX
Mvc4
Muhammad Younis
Ā 
PPTX
Will be an introduction to
Sayed Ahmed
Ā 
PPTX
ASP.NET - Building Web Application..in the right way!
Commit Software Sh.p.k.
Ā 
PPTX
ASP.NET - Building Web Application..in the right way!
Fioriela Bego
Ā 
PPTX
Web API with ASP.NET MVC by Software development company in india
iFour Institute - Sustainable Learning
Ā 
PDF
Unleash the power of HTTP with ASP.NET Web API
Filip W
Ā 
PPTX
Mastering-ASPNET-Web-API-and-RESTful-Patterns.pptx
keshabregmi1
Ā 
PPTX
Web api
Sudhakar Sharma
Ā 
PPTX
ZZ BC#8 Hello ASP.NET MVC 4 (dks)
Chalermpon Areepong
Ā 
PDF
ASP NET Web API 2 Building a REST Service from Start to Finish 2nd Edition Ja...
prienmance8p
Ā 
PPT
Excellent rest using asp.net web api
Maurice De Beijer [MVP]
Ā 
ASP.NET Web API Interview Questions By Scholarhat
Scholarhat
Ā 
Asp.net web api
Binu Bhasuran
Ā 
C# web api
Simplilearn
Ā 
Web API or WCF - An Architectural Comparison
Adnan Masood
Ā 
ASP.NET Mvc 4 web api
Tiago Knoch
Ā 
Complete guidance book of Asp.Net Web API
Shabista Imam
Ā 
Difference between wcf and asp.net web api
Umar Ali
Ā 
ASP.NET Core 1 for MVC- and WebAPI-Devs
Manfred Steyer
Ā 
CodeCamp Iasi 10 March 2012 - Gabriel Enea - ASP.NET Web API
Codecamp Romania
Ā 
Will be an introduction to
Sayed Ahmed
Ā 
ASP.NET - Building Web Application..in the right way!
Commit Software Sh.p.k.
Ā 
ASP.NET - Building Web Application..in the right way!
Fioriela Bego
Ā 
Web API with ASP.NET MVC by Software development company in india
iFour Institute - Sustainable Learning
Ā 
Unleash the power of HTTP with ASP.NET Web API
Filip W
Ā 
Mastering-ASPNET-Web-API-and-RESTful-Patterns.pptx
keshabregmi1
Ā 
Web api
Sudhakar Sharma
Ā 
ZZ BC#8 Hello ASP.NET MVC 4 (dks)
Chalermpon Areepong
Ā 
ASP NET Web API 2 Building a REST Service from Start to Finish 2nd Edition Ja...
prienmance8p
Ā 
Excellent rest using asp.net web api
Maurice De Beijer [MVP]
Ā 
Ad

More from Umar Ali (20)

PDF
Difference between ActionResult() and ViewResult()
Umar Ali
Ā 
PDF
Difference between asp.net mvc 3 and asp.net mvc 4
Umar Ali
Ā 
PDF
Difference between asp.net web forms and asp.net mvc
Umar Ali
Ā 
PDF
ASP.NET MVC difference between questions list 1
Umar Ali
Ā 
ODT
Link checkers 1
Umar Ali
Ā 
PDF
Affiliate Networks Sites-1
Umar Ali
Ā 
PDF
Technical Video Training Sites- 1
Umar Ali
Ā 
PDF
US News Sites- 1
Umar Ali
Ā 
PDF
How to create user friendly file hosting link sites
Umar Ali
Ā 
PDF
Weak hadiths in tamil
Umar Ali
Ā 
PDF
Bulughul Maram in tamil
Umar Ali
Ā 
PDF
Asp.net website usage and job trends
Umar Ali
Ā 
PDF
Indian news sites- 1
Umar Ali
Ā 
PDF
Photo sharing sites- 1
Umar Ali
Ā 
PDF
File hosting search engines
Umar Ali
Ā 
PDF
Ajax difference faqs compiled- 1
Umar Ali
Ā 
PDF
ADO.NET difference faqs compiled- 1
Umar Ali
Ā 
PDF
Dotnet differences compiled -1
Umar Ali
Ā 
PDF
.NET Differences List
Umar Ali
Ā 
PDF
Difference between ajax and silverlight
Umar Ali
Ā 
Difference between ActionResult() and ViewResult()
Umar Ali
Ā 
Difference between asp.net mvc 3 and asp.net mvc 4
Umar Ali
Ā 
Difference between asp.net web forms and asp.net mvc
Umar Ali
Ā 
ASP.NET MVC difference between questions list 1
Umar Ali
Ā 
Link checkers 1
Umar Ali
Ā 
Affiliate Networks Sites-1
Umar Ali
Ā 
Technical Video Training Sites- 1
Umar Ali
Ā 
US News Sites- 1
Umar Ali
Ā 
How to create user friendly file hosting link sites
Umar Ali
Ā 
Weak hadiths in tamil
Umar Ali
Ā 
Bulughul Maram in tamil
Umar Ali
Ā 
Asp.net website usage and job trends
Umar Ali
Ā 
Indian news sites- 1
Umar Ali
Ā 
Photo sharing sites- 1
Umar Ali
Ā 
File hosting search engines
Umar Ali
Ā 
Ajax difference faqs compiled- 1
Umar Ali
Ā 
ADO.NET difference faqs compiled- 1
Umar Ali
Ā 
Dotnet differences compiled -1
Umar Ali
Ā 
.NET Differences List
Umar Ali
Ā 
Difference between ajax and silverlight
Umar Ali
Ā 

Recently uploaded (20)

PDF
Building High-Performance Oracle Teams: Strategic Staffing for Database Manag...
SMACT Works
Ā 
PPTX
cloud computing vai.pptx for the project
vaibhavdobariyal79
Ā 
PDF
SparkLabs Primer on Artificial Intelligence 2025
SparkLabs Group
Ā 
PPT
Coupa-Kickoff-Meeting-Template presentai
annapureddyn
Ā 
PDF
DevOps & Developer Experience Summer BBQ
AUGNYC
Ā 
PPTX
Stamford - Community User Group Leaders_ Agentblazer Status, AI Sustainabilit...
Amol Dixit
Ā 
PDF
How-Cloud-Computing-Impacts-Businesses-in-2025-and-Beyond.pdf
Artjoker Software Development Company
Ā 
PPTX
Coupa-Overview _Assumptions presentation
annapureddyn
Ā 
PDF
Revolutionize Operations with Intelligent IoT Monitoring and Control
Rejig Digital
Ā 
PDF
Why Your AI & Cybersecurity Hiring Still Misses the Mark in 2025
Virtual Employee Pvt. Ltd.
Ā 
PDF
Cloud-Migration-Best-Practices-A-Practical-Guide-to-AWS-Azure-and-Google-Clou...
Artjoker Software Development Company
Ā 
PPTX
Smart Infrastructure and Automation through IoT Sensors
Rejig Digital
Ā 
PDF
Orbitly Pitch Deck|A Mission-Driven Platform for Side Project Collaboration (...
zz41354899
Ā 
PDF
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
Ā 
PDF
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
Ā 
PPTX
What-is-the-World-Wide-Web -- Introduction
tonifi9488
Ā 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
Ā 
PPTX
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
Ā 
PDF
Software Development Methodologies in 2025
KodekX
Ā 
PDF
REPORT: Heating appliances market in Poland 2024
SPIUG
Ā 
Building High-Performance Oracle Teams: Strategic Staffing for Database Manag...
SMACT Works
Ā 
cloud computing vai.pptx for the project
vaibhavdobariyal79
Ā 
SparkLabs Primer on Artificial Intelligence 2025
SparkLabs Group
Ā 
Coupa-Kickoff-Meeting-Template presentai
annapureddyn
Ā 
DevOps & Developer Experience Summer BBQ
AUGNYC
Ā 
Stamford - Community User Group Leaders_ Agentblazer Status, AI Sustainabilit...
Amol Dixit
Ā 
How-Cloud-Computing-Impacts-Businesses-in-2025-and-Beyond.pdf
Artjoker Software Development Company
Ā 
Coupa-Overview _Assumptions presentation
annapureddyn
Ā 
Revolutionize Operations with Intelligent IoT Monitoring and Control
Rejig Digital
Ā 
Why Your AI & Cybersecurity Hiring Still Misses the Mark in 2025
Virtual Employee Pvt. Ltd.
Ā 
Cloud-Migration-Best-Practices-A-Practical-Guide-to-AWS-Azure-and-Google-Clou...
Artjoker Software Development Company
Ā 
Smart Infrastructure and Automation through IoT Sensors
Rejig Digital
Ā 
Orbitly Pitch Deck|A Mission-Driven Platform for Side Project Collaboration (...
zz41354899
Ā 
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
Ā 
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
Ā 
What-is-the-World-Wide-Web -- Introduction
tonifi9488
Ā 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
Ā 
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
Ā 
Software Development Methodologies in 2025
KodekX
Ā 
REPORT: Heating appliances market in Poland 2024
SPIUG
Ā 

Difference between asp.net web api and asp.net mvc

  • 1. S.No ASP.NET Web API ASP.NET MVC 1 Purpose of ASP.NET MVC: To create web applications that returns both views and data. Purpose of ASP.NET Web API: To create full blown HTTP services with easy and simple way that returns only data not view. i.e., ASP.NET Web API is focused on making output of raw data easy. i.e., ASP.NET MVC is focused on making output of HTML easy. In the WebForms world, ASP.NET MVC In the WebForms world, ASP.NET Web API would be equivalent to .aspx pages. would be equivalent to .asmx pages. 2 Default Assumption for ASP.NET Web API: ASP.NET Web API by default assumes that primitive type comes from query string and non-primitive types comes from the form. It also assumes that we would only want to read the form body once, without caching, to have lower memory usage and better performance. Default Assumption for ASP.NET MVC: ASP.NET MVC by default assumes user submitted data can come from multiple sources, be it in the query string or in the form. 3 Whether it is possible to make ASP.NET Web API output HTML ? Yes Whether it is possible to make ASP.NET MVC output raw data ? Yes But, we need to do some additional work as But, we need to do some additional work as provided below, provided below, Making additional classes to handle text/html during content negotiation in ASP.NET Web API. Adding logic to handle OData queries in ASP.NET MVC. 4 GET AJAX Request in ASP.NET Web API: ASP.NET Web API allows GET AJAX request by default. GET AJAX Request in ASP.NET MVC: GET AJAX request is blocked by ASP.NET MVC's JsonResult by default to prevent CSRF. 5 Whether RESTful services can be created with ASP.NET Web API ? ASP.NET Web API helps the creation of RESTful services over the .Net Framework. Whether RESTful services can be created with ASP.NET MVC ? With ASP.NET MVC, we cannot able to create RESTful services. 6 Return format of data: ASP.NET Web API returns the data in various formats, such as JSON, XML and other format based on the accept header of the request. Return format of data: ASP.NET MVC returns the data in the JSON format by using JSONResult. 7 Request Mapping: Request Mapping: In ASP.NET Web API the request are In ASP.NET MVC the request is mapped to mapped to the actions based on HTTP verbs. actions name. 8 Where we can see the features such as: model binding, filters, routing etc., in Where we can see the features such as: model binding, filters, routing etc., in
  • 2. ASP.NET Web API ? System.Web.Http 9 ASP.NET MVC? System.Web.Mvc Whether content negotiation and self hosting features are supported ? ASP.NET Web API supports content negotiation, self hosting. Whether content negotiation and self hosting features are supported ? ASP.NET MVC does not support content negotiation and self hosting features. Content Negatiotion – It is about deciding the best response format data that could be acceptable by the client. it could be JSON,XML,ATOM or other formatted data 10 How routing is defined in ASP.NET Web API? Routing is defined by webapiconfig class i.e., using MapHttpRoute method. How routing is defined in ASP.NET MVC? Routing is defined by routeconfig class i.e., using MapRoute method . Unlike MVC, Routing API here does not use any reference to MVC . 11 When to use ASP.NET Web API? Web API is more capable of supporting many different clients,namely, WPF Client, iPhone, Android, iPad, Windows Phone 7, Windows Phone 8, Web Browsers: IE, Firefox, Chrome etc., then ASP.NET Web API is likely going to be a better choice. When to use ASP.NET MVC? Asp.NET MVC is optimized for having a web browser as a client. If our only client is a web browser, then MVC is likely going to be a better choice. Note: 1.We can mix Web API and MVC controller in a single project to handle advanced AJAX requests which may return data in JSON, XML or any others format and building a full blown HTTP service. Typically, this will be called Web API self hosting. 2.When we have mixed MVC and Web API controller and you want to implement the authorization then we have to create two filters one for MVC and another for Web API since boths are different. Reference: http://onlydifferencefaqs.blogspot.in/2014/02/difference-between-aspnet-web-api-and.html