Web API Interview Questions - CodeProject
Web API Interview Questions - CodeProject
codeproject.com
Optimized just now
View original
Submit
articles
Q&A
forums
Lounge
Technical
Blog Top 10 ASP.NET Web API Interview Go
to
View top
Blog Questions
Alternatives
Comments
(5)
250.9K
views
Top 10 interview questions related to ASP.NET Web API framework
35
bookmarked In
this ASP.NET Interview Questions Series, so far we have covered
questions related to the core of ASP.NET technology. In this part-6 of
Posted 5 May ASP.NET Tutorial series, we will cover top 10 interview questions related
2014
to ASP.NET Web API framework.
Using ASP.NET Web API, we can create non-SOAP based services like
plain XML or JSON strings, etc. with many other advantages including:
Using ASP.NET Web API has a number of advantages, but core of the
advantages are:
It works the HTTP way using standard HTTP verbs like GET, POST, PUT,
DELETE, etc. for all CRUD operations
Complete support for routing
Response generated in JSON or XML format using
MediaTypeFormatter
It has the ability to be hosted in IIS as well as self-host outside of IIS
Supports Model binding and Validation
Support for OData
and more....
More new features introduced in ASP.NET Web API framework v2.0 are
as follows:
Attribute Routing
External Authentication
CORS (Cross-Origin Resource Sharing)
OWIN (Open Web Interface for .NET) Self Hosting
IHttpActionResult
Web API OData
You can follow a good Web API new feature details on Top 5 New
Features in ASP.NET Web API 2 here.
It's a misconception that ASP.NET Web API has replaced WCF. It's
another way of building non-SOAP based services, for example, plain
XML or JSON string, etc.
Yes, it has some added advantages like utilizing full features of HTTP
and reaching more clients such as mobile devices, etc.
(A tricky Interview question) No, we can't return view from ASP.NET Web
API method. We discussed in the earlier interview question about the
difference between ASP.NET MVC and Web API that ASP.NET Web API
creates HTTP services that renders raw data. Although, it's quite possible
in ASP.NET MVC application.
Attribute programming plays its role here. We can easily restrict access
to an ASP.NET Web API method to be called using a specific HTTP
method. For example, we may require in a scenario to restrict access to a
Web API method through HTTP POSTonly as follows:
Hide Copy Code
[HttpPost]
public void UpdateStudent(Student aStudent)
{
StudentRepository.AddStudent(aStudent);
}
Can we use Web API with ASP.NET Web Form?
Yes, ASP.NET Web API is bundled with ASP.NET MVC framework but still
it can be used with ASP.NET Web Form.
jQuery call to Web API for all CRUD (Create, Retrieve, Update, Delete)
operations can be found here.
How Can We Provide an Alias Name for ASP.NET Web API Action?
We can provide an alias name for ASP.NET Web API action same as in
case of ASP.NET MVC by using "ActionName" attribute as follows:
Hide Copy Code
[HttpPost]
[ActionName("SaveStudentInfo")]
public void UpdateStudent(Student aStudent)
{
StudentRepository.AddStudent(aStudent);
}
License