S.No
|
ASP.NET Web API
|
ASP.NET MVC
|
1 |
Purpose of ASP.NET Web API:
To create full blown HTTP services
with easy and simple way that returns only data not view.
In the WebForms world, ASP.NET Web
API would be equivalent to .asmx pages.
|
Purpose of ASP.NET MVC:
To create web applications that
returns both views and data.
i.e., ASP.NET MVC is focused on
making output of HTML easy.
In the WebForms world, ASP.NET MVC
would be equivalent to .aspx 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
Making additional classes to handle text/html during content negotiation in ASP.NET Web API. |
Whether it is possible to make ASP.NET MVC output raw data
?
Yes
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:
In ASP.NET Web API the request are
mapped to the actions based on HTTP verbs.
|
Request Mapping:
In ASP.NET MVC the request is
mapped to actions name.
|
8 |
Where we can see the features such as: model binding,
filters, routing etc., in ASP.NET Web API ?
System.Web.Http
|
Where we can see the features such as: model binding,
filters, routing etc., in ASP.NET MVC?
System.Web.Mvc
|
9 |
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.
|
10 |
How routing is defined in ASP.NET Web API?
Routing is defined by webapiconfig
class i.e., using MapHttpRoute method.
Unlike MVC, Routing API here does not use any reference to MVC . |
How routing is defined in ASP.NET MVC?
Routing is defined by routeconfig
class i.e., using MapRoute method .
|
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.
Nice work, your blog is concept-oriented, kindly share more blogs like this
ReplyDeleteDot NET Online Course Bangalore
nice post.dot net training
ReplyDeletedot net online training