In this ASP.NET Web API tutorial, we are going to discuss about the top features in ASP.NET Web API 2.1. We have already discussed about Top 5 features in ASP.NET Web API 2.0 in a separate post on this Web Development blog.
ASP.NET Web API is a framework for building HTTP services for broader range of clients i.e. browsers as well as mobile devices, on top of .NET Framework. Using ASP.NET Web API we can create non-SOAP based services like plain XML or JSON strings etc. with many other added advantages including:
- Create resource-oriented services using the full features of HTTP.
- Exposing services to a variety of clients easily like browsers or mobile devices etc.
Note: You can download a PDF version of “A Practical Guide to ASP.NET Web API” here or read Online Version here.
Following are the new exciting features in ASP.NET Web API 2.1 straight from Microsoft ASP.NET Web API Team:
- Global error handling
- Attribute routing improvements
- Help Page improvements
- IgnoreRoute support
- BSON media-type formatter
- Better support for async filters
- Query parsing for the client formatting library
- Various bug fixes
Attribute Routing Improvements:
ASP.NET Web API first provided support for Attribute Routing along with convention-based routing in version 2.0. We discussed in detail about Attribute Routing in a separate post “Attribute Routing ASP.NET Web API 2.0“. With attribute routing, support for certain URI pattern was provided like nested routing on same controller.
In version 2.1, using IDirectRouteFactory interface and RouteFactoryAttribute class, attribute routes are customizable now.
ASP.NET Web API Team further enhanced Attribute routing feature as it now supports:
- Constraints
- Enabled versioning
- Header-based Route selection
Global Error Handling:
As ASP.NET Web API generates response for a variety of clients (browsers and mobile devices etc.), so a central mechanism is needed for handling all unhandled exceptions in a more organized and robust way. ASP.NET Web API now support for Global Error Handling which is basically a more controlled way of handling all unhandled exceptions. It’s now equipped with multiple exception loggers looking for unhandled exception and related information. It also facilitates for generating a fully customizable HTTP response message in case an unhandled exception occurs.
Web API Help Page Improvements:
Web API Help Page is a good way to facilitate other developers that how they can consume our ASP.NET Web API
service. A library was already available to auto-generate help pages at run time. But in Web API 2.1, further enhancements provided to Web API Help Pages including
- documenting properties of an action’s parameter or return types.
- documenting data model annotations.
Hopefully, above post will be helpful and we will keep exploring new and exciting features of ASP.NET Web API.
Other Related Articles:
- A practical guide to ASP.NET Web API
- Building your First ASP.NET MVC 5 Application
- WebForms Vs ASP.NET MVC
- Solution to browser back button event
- What’s new in WCF 4.5
- WCF Tutorial step by step
- Creating your first WCF REST Service
Top 10 Interview Questions and Answers Series:
- Top 10 HTML5 Interview Questions
- Top 10 ASP.NET Interview Questions
- Comprehensive Series of ASP.NET Interview Questions
- Top 10 ASP.NET MVC Interview Questions
- Top 10 ASP.NET Web API Interview Questions
- Top 10 ASP.NET AJAX Interview Questions
- Top 10 WCF Interview Questions
- Comprehensive Series of WCF Interview Questions