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

What's hot (20)

Hibernate Presentation
Hibernate Presentation
guest11106b
 
Swing
Swing
Jaydeep Viradiya
 
What Is Express JS?
What Is Express JS?
Simplilearn
 
REST APIs with Spring
REST APIs with Spring
Joshua Long
 
Spring boot introduction
Spring boot introduction
Rasheed Waraich
 
jstl ( jsp standard tag library )
jstl ( jsp standard tag library )
Adarsh Patel
 
Asp.net control
Asp.net control
Paneliya Prince
 
Report.docx
Report.docx
KaliaLawFirm
 
Spring mvc
Spring mvc
Pravin Pundge
 
Class 5 - PHP Strings
Class 5 - PHP Strings
Ahmed Swilam
 
Spring Boot
Spring Boot
Jiayun Zhou
 
Java 8 features
Java 8 features
NexThoughts Technologies
 
Back to the Basics - 1 - Introduction to Web Development
Back to the Basics - 1 - Introduction to Web Development
Clint LaForest
 
Spring data jpa
Spring data jpa
Jeevesh Pandey
 
Spring Boot
Spring Boot
HongSeong Jeon
 
Spring Data JPA
Spring Data JPA
Cheng Ta Yeh
 
Spring Boot
Spring Boot
Jaran Flaath
 
Java Persistence API (JPA) Step By Step
Java Persistence API (JPA) Step By Step
Guo Albert
 
Java Spring Framework
Java Spring Framework
Mehul Jariwala
 
Angular introduction students
Angular introduction students
Christian John Felix
 

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

ASP.NET Web API Interview Questions By Scholarhat
ASP.NET Web API Interview Questions By Scholarhat
Scholarhat
 
Asp.net web api
Asp.net web api
Binu Bhasuran
 
C# web api
C# web api
Simplilearn
 
Web API or WCF - An Architectural Comparison
Web API or WCF - An Architectural Comparison
Adnan Masood
 
ASP.NET Mvc 4 web api
ASP.NET Mvc 4 web api
Tiago Knoch
 
Difference between wcf and asp.net web api
Difference between wcf and asp.net web api
Umar Ali
 
ASP.NET Core 1 for MVC- and WebAPI-Devs
ASP.NET Core 1 for MVC- and WebAPI-Devs
Manfred Steyer
 
CodeCamp Iasi 10 March 2012 - Gabriel Enea - ASP.NET Web API
CodeCamp Iasi 10 March 2012 - Gabriel Enea - ASP.NET Web API
Codecamp Romania
 
Mvc4
Mvc4
Muhammad Younis
 
Will be an introduction to
Will be an introduction to
Sayed Ahmed
 
ASP.NET - Building Web Application..in the right way!
ASP.NET - Building Web Application..in the right way!
Commit Software Sh.p.k.
 
ASP.NET - Building Web Application..in the right way!
ASP.NET - Building Web Application..in the right way!
Fioriela Bego
 
Web API with ASP.NET MVC by Software development company in india
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
Unleash the power of HTTP with ASP.NET Web API
Filip W
 
Web api
Web api
Sudhakar Sharma
 
ZZ BC#8 Hello ASP.NET MVC 4 (dks)
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...
ASP NET Web API 2 Building a REST Service from Start to Finish 2nd Edition Ja...
prienmance8p
 
Excellent rest using asp.net web api
Excellent rest using asp.net web api
Maurice De Beijer [MVP]
 
MVC 4
MVC 4
Vasilios Kuznos
 
Enjoying the Move from WCF to the Web API
Enjoying the Move from WCF to the Web API
Kevin Hazzard
 
ASP.NET Web API Interview Questions By Scholarhat
ASP.NET Web API Interview Questions By Scholarhat
Scholarhat
 
Web API or WCF - An Architectural Comparison
Web API or WCF - An Architectural Comparison
Adnan Masood
 
ASP.NET Mvc 4 web api
ASP.NET Mvc 4 web api
Tiago Knoch
 
Difference between wcf and asp.net web api
Difference between wcf and asp.net web api
Umar Ali
 
ASP.NET Core 1 for MVC- and WebAPI-Devs
ASP.NET Core 1 for MVC- and WebAPI-Devs
Manfred Steyer
 
CodeCamp Iasi 10 March 2012 - Gabriel Enea - ASP.NET Web API
CodeCamp Iasi 10 March 2012 - Gabriel Enea - ASP.NET Web API
Codecamp Romania
 
Will be an introduction to
Will be an introduction to
Sayed Ahmed
 
ASP.NET - Building Web Application..in the right way!
ASP.NET - Building Web Application..in the right way!
Commit Software Sh.p.k.
 
ASP.NET - Building Web Application..in the right way!
ASP.NET - Building Web Application..in the right way!
Fioriela Bego
 
Unleash the power of HTTP with ASP.NET Web API
Unleash the power of HTTP with ASP.NET Web API
Filip W
 
ZZ BC#8 Hello ASP.NET MVC 4 (dks)
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...
ASP NET Web API 2 Building a REST Service from Start to Finish 2nd Edition Ja...
prienmance8p
 
Enjoying the Move from WCF to the Web API
Enjoying the Move from WCF to the Web API
Kevin Hazzard
 
Ad

More from Umar Ali (20)

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

Recently uploaded (20)

Data Validation and System Interoperability
Data Validation and System Interoperability
Safe Software
 
FIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance
 
FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Alliance
 
PyData - Graph Theory for Multi-Agent Integration
PyData - Graph Theory for Multi-Agent Integration
barqawicloud
 
Murdledescargadarkweb.pdfvolumen1 100 elementary
Murdledescargadarkweb.pdfvolumen1 100 elementary
JorgeSemperteguiMont
 
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Alliance
 
Oracle Cloud Infrastructure AI Foundations
Oracle Cloud Infrastructure AI Foundations
VICTOR MAESTRE RAMIREZ
 
Oracle Cloud Infrastructure Generative AI Professional
Oracle Cloud Infrastructure Generative AI Professional
VICTOR MAESTRE RAMIREZ
 
Crypto Super 500 - 14th Report - June2025.pdf
Crypto Super 500 - 14th Report - June2025.pdf
Stephen Perrenod
 
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
Safe Software
 
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
Safe Software
 
Oracle Cloud and AI Specialization Program
Oracle Cloud and AI Specialization Program
VICTOR MAESTRE RAMIREZ
 
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Puppy jhon
 
Floods in Valencia: Two FME-Powered Stories of Data Resilience
Floods in Valencia: Two FME-Powered Stories of Data Resilience
Safe Software
 
Introduction to Typescript - GDG On Campus EUE
Introduction to Typescript - GDG On Campus EUE
Google Developer Group On Campus European Universities in Egypt
 
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Alliance
 
“Addressing Evolving AI Model Challenges Through Memory and Storage,” a Prese...
“Addressing Evolving AI Model Challenges Through Memory and Storage,” a Prese...
Edge AI and Vision Alliance
 
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Anish Kumar
 
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
NTT DATA Technology & Innovation
 
Enabling BIM / GIS integrations with Other Systems with FME
Enabling BIM / GIS integrations with Other Systems with FME
Safe Software
 
Data Validation and System Interoperability
Data Validation and System Interoperability
Safe Software
 
FIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance
 
FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Alliance
 
PyData - Graph Theory for Multi-Agent Integration
PyData - Graph Theory for Multi-Agent Integration
barqawicloud
 
Murdledescargadarkweb.pdfvolumen1 100 elementary
Murdledescargadarkweb.pdfvolumen1 100 elementary
JorgeSemperteguiMont
 
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Alliance
 
Oracle Cloud Infrastructure AI Foundations
Oracle Cloud Infrastructure AI Foundations
VICTOR MAESTRE RAMIREZ
 
Oracle Cloud Infrastructure Generative AI Professional
Oracle Cloud Infrastructure Generative AI Professional
VICTOR MAESTRE RAMIREZ
 
Crypto Super 500 - 14th Report - June2025.pdf
Crypto Super 500 - 14th Report - June2025.pdf
Stephen Perrenod
 
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
Safe Software
 
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
Safe Software
 
Oracle Cloud and AI Specialization Program
Oracle Cloud and AI Specialization Program
VICTOR MAESTRE RAMIREZ
 
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Puppy jhon
 
Floods in Valencia: Two FME-Powered Stories of Data Resilience
Floods in Valencia: Two FME-Powered Stories of Data Resilience
Safe Software
 
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Alliance
 
“Addressing Evolving AI Model Challenges Through Memory and Storage,” a Prese...
“Addressing Evolving AI Model Challenges Through Memory and Storage,” a Prese...
Edge AI and Vision Alliance
 
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Anish Kumar
 
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
NTT DATA Technology & Innovation
 
Enabling BIM / GIS integrations with Other Systems with FME
Enabling BIM / GIS integrations with Other Systems with FME
Safe Software
 

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