
Explore how real-world Web API services map HTTP verbs and URLs to controller actions within a lightweight, extensible pipeline on the .NET framework.
Create an empty web api project in visual studio and configure WebApiConfig routing for api/values. Add a values controller with get methods to show content negotiation returning xml or json.
Explore the Azure API app template for Web API projects, review Swagger and Application Insights integration, and note it can run on-premise while remaining similar to a blank template.
Explore how the web api implements the model-view-controller pattern with controllers, action methods, and routes. Create a basic project and learn integration testing approaches for local validation and production readiness.
Learn to perform end-to-end integration testing of a web API by sending all HTTP verbs, headers, and tokens, and test the entire pipeline from your local machine.
Use Fiddler to test web API calls, inspect request and response headers in XML or JSON, and experiment with verbs and content negotiation.
Explore Postman as the primary tool for API testing, demonstrating headers manipulation, content negotiation (json/xml), request collections, authentication tokens, and sharing test libraries.
Install swashbuckle to generate swagger documentation for your asp.net web api, access /swagger, test methods and content negotiation in the browser, and view a self-documenting API for your service.
Test the web API pipeline with Fiddler, Postman, and Swagger via swashbuckle, and learn routing by comparing attributes and templates in controller mappings.
Learn how Web API routes requests to controllers and actions, emphasizing readable, maintainable routing. Validate and secure URL and body parameters, use HTTP verbs, and dynamically generate URLs.
Explore the strengths and weaknesses of template style routing, test with Swagger across multiple controllers, and learn how attributes and legacy routes improve control over http verbs and method naming.
Use attribute based routing to define per-method routes and a controller prefix, replacing template routes and centralizing url patterns. Override the prefix to tailor api/products urls and support multi-parameter routes.
Constrain route parameters with built-in constraints and regular expressions to validate input, prevent mismatches, and boost security by enforcing ranges and patterns across routes.
Create and register custom route constraints in ASP.NET Web API by implementing IHttpRouteConstraint, supporting enumeration checks, and wiring a custom constraint resolver for dynamic parameter validation.
Use AcceptVerbs to trigger actions with nonstandard http verbs and map multiple routes to the same controller, and name routes to build self-referencing urls with Url.Link, noting proxy considerations.
Define optional route parameters with default values in a .NET web API, using route definitions or method defaults, and test with Postman since Swagger lacks helpful testing support.
Avoid route conflicts by simplifying API semantics, or if unavoidable, define route order to set precedence; understand Web API's resolution: literal segments first, then constrained parameters, then wildcards.
Learn how Web API binds URL and body data to C# action parameters via model binding, with custom binders, FromUri and FromBody attributes, and JSON, XML, and form formatters.
Bind remaining URL segments with wildcard parameters in Web API routing using a custom binder for string arrays; useful for date-like paths or IoT data, though body data is preferred.
Master routing and parameter binding in ASP.NET Web API by using attribute routing, parameter constraints, and custom binders, while generating URLs via route names and supporting various HTTP verbs.
Explore the real world ASP.NET Web API pipeline, from message-layer processing with delegating handlers to routing, authentication and authorization, model binding, and formatters that shape requests and responses.
Discover an opinionated approach to real world Web API design, prioritizing attribute routing and a layered pipeline with message handlers, authentication filters, and per-route action filters.
Explore delegating handlers in the Web API pipeline, which are asynchronous and daisy-chained, handling requests and responses in a single SendAsync method. Register them in WebApiConfig and consider dependency injection.
Create and test a delegating handler that times the request pipeline, logs the elapsed time, and adds a custom response header, then register it in WebApiConfig.
Discover a real-world API key delegating handler that accepts keys from HTTP headers or Swagger's query string, stores them in request properties, and uses a dedicated authorization filter.
Examine the limits of delegating handlers by removing or overriding security headers such as X-AspNet-Version and X-Powered-By, and learn to address these issues in web.config and IIS.
Develop a delegating handler to derive the client perspective base URL and rebasing generated URLs for the client using X-Forwarded, Forwarded headers and Url.Link.
Explore the Web API pipeline in layers, using delegating handlers for analytics, timing, and header processing, store data in request properties, and extract load balancer headers and the client IP.
Understand how action filters operate after authentication and model binding in the Web API pipeline, enabling per-route logic, validation, and analytics, while avoiding use for binding or authentication tasks.
Action filters are attributes attached to routes that run code before and after an action method, and can be registered globally or per route or per controller, with per-route overrides.
Implement a route timer using an action filter, store a stopwatch, log elapsed time, and add a header; compare per-route and global filters and the pipeline costs.
Explore a practical client side caching action filter that uses http headers to balance performance and freshness, supporting public, private, or no cache and configurable seconds.
Explore how action method return types affect content negotiation, error handling, and pipeline behavior in real-world ASP.NET Web API services, comparing object results, HttpResponseMessage, and IHttpActionResult.
Explore return types in real-world web api design, from void and complex types to HttpResponseMessage, including CreateResponse and CreateErrorResponse patterns with content negotiation.
Explore IHttpActionResult as a promise that defers to an HttpResponseMessage, letting ApiController return negotiated content, errors, and custom headers, with fluent extensions for per-result caching.
Explore using action filters to enforce model validation on posted body data with data annotations, handling ModelState and global application, including required versus optional FromBody parameters.
demonstrates a validate model state action filter with an optional body required flag. aborts the pipeline when the FromBody parameter is missing or null.
Examine action filters and delegating handlers in the web api pipeline, learn to short-circuit the pipeline, validate inbound data, and customize responses with route or global filters.
Explore real world authentication in ASP.NET web api, focusing on security tokens, authorization header, and token schemes such as basic and bearer, including custom authentication.
Learn to implement authentication filters with a boilerplate template, convert tokens into an IPrincipal, suppress the host principal, and validate credentials via AuthenticateAsync.
Build an IHttpActionResult authentication filter that uses ExecuteAsync to return an HttpResponseMessage with a customizable reason phrase, and validate credentials to produce an IPrincipal with an IIdentity.
Turn the template into a functional basic authentication filter for an ASP.NET Web API project by parsing base64 credentials, validating against abc123, and building a claims identity and principal.
Create and test a basic authentication filter for a Web API by examining IPrincipal, ClaimsIdentity, and the authorization flow, ensuring anonymous handling and proper WWW-Authenticate prompts.
Learn how JWT-based tokens enable claims-based authentication, are digitally signed with an X509 certificate, and validated locally using a JWT authentication filter with bearer authorization.
validate a bearer jwt token with a custom authentication filter, verifying audience, issuer, and signature using certificate-based signing credentials, yielding a claims principal and optional extra claims.
Demonstrates creating and validating a custom jwt authentication filter for a real world asp.net web api service, inspecting audience, issuer, claims, and bootstrap context to build authorization headers.
Override the authentication filter list to allow only a chosen token type for a method, such as JWT, while global filters include Basic and JWT.
Explore the architecture of authentication filters in web APIs, covering basic and JWT authentication, HTTP authorization headers, and reusable API key handling within a layered pipeline.
Learn how authorization secures ASP.NET Web API by validating request contents and identity, using authorization filters at global or action level to enforce https, tokens, or api keys.
Authorization filters in ASP.NET Web API rely on OnAuthorizationAsync to decide access; if unauthorized, they abort with a 403 or 404, otherwise they proceed asynchronously for peak performance.
The Authorize attribute validates the IPrincipal, with optional role or user name checks, while AllowAnonymous lets specific methods bypass authorization, enabling flexible, real-world security configurations.
Enforce a require https authorization filter by inspecting the client's perspective url via GetSelfReferenceBaseUrl and load balancer headers; abort with 403 'https required' if not https, otherwise pass through.
Learn how the RequireClaim authorization filter enforces specific claims in a ClaimsIdentity regardless of token type, and returns 401 or 403 responses while optionally exposing missing claims.
Review the simple structure of authorization filters and how they block or allow requests. Learn about the Authorize and AllowAnonymous attributes, Require HTTPS and RequireClaims, and the API key filter.
Understand how Web API handles errors via analyzers, converters, and exception filters. Learn to implement a global exception handler and a last-resort ASP.NET path to craft safe HTTP error responses.
Identify Application_Error() as the exception handler of last resort for errors outside the web API pipeline, log and email critical failures, and apply IncludeErrorDetailPolicy and customErrors for production.
Use exception filters for localized, controller or action-specific handling of intentional exceptions, converting them into tailored HTTP responses with specific status codes and reason phrases.
Explore how the global exception handler converts unhandled exceptions into concise responses, bypassing stack traces, using exception filters and optional inner handlers with content negotiation for responses.
Learn how global exception loggers augment handling by allowing multiple single-purpose loggers, such as log4net or Elmah, to record, email, or analyze errors with context.
Explore RFC 7807 problem responses and how they standardize error details beyond generic 500s, introducing a media type, json and xml, and five reserved fields: type, title, status, detail, instance.
Explore implementing RFC 7807 problem details in a complete error handling system for web APIs, using a NuGet package, with type, title, detail, instance, and extensions.
Leverage RFC 7807 to standardize errors in web api using RFC7807Exception, problem detail structures, a content negotiator, and integration with HttpResponseMessage, IHttpActionResult, and a global exception handler.
Integrate the RFC 7807 library into a web api to produce RFC-style problem details for exceptions and status codes, using a global handler, custom problem details, and response extensions.
Navigate the complexities of error handling in real world ASP.NET Web API services, introducing RFC 7807 to describe errors and showcasing global exception handling, filters, and loggers.
Explore practical techniques for real world web API services, including Swagger hints, handling CORS, and defining a Microsoft API versioning strategy before v1.0.
Configure Swashbuckle to send the API key in a header rather than a query string, and dynamically set Swagger's root URL behind load balancers using forwarded headers.
Become the go-to expert in real world restful web services with production ready code, covering route constraints, Swagger, performance analytics, testing, and asynchronous design.
Become the Expert!
Are you a C#.NET developer ready to take the plunge into microservices?
Microsoft's ASP.NET Web API 2.0 for .NET Framework is an outstanding, flexible platform for creating microservices. Unfortunately the official documentation is sparse, and you are left trying to piece together your understanding of this powerful platform by scouring the Internet for articles and examples that are often too academic, outdated, and not aligned with the practical needs of real-world services that must integrate with potentially many different kinds of clients and data center environments.
In this course, I will take you step by step through all of the layers of Web API to give you a full understanding of the platform components you will likely need to use in a modern, production-ready web service. Examples and exercises are drawn from practical, real-world scenarios of the sort I personally faced while creating commercial web services-- and chances are you will face them too!
We'll cover all of the core Web API features like
securing your API parameters,
extending the Web API to perform custom processing,
error handling,
authentication and authorization.
We'll look at ways to test and document your service. We'll dig into performance improvements using techniques like caching and asynchronous operations. You'll get a clear understanding of how to make your service work correctly behind application proxies such as load balancers that every commercial web service uses in the real world.
I've put together everything you need in one place to create professional, production-ready Web API services. This course will save you many hours of time and give you a much deeper understanding of everything Web API has to offer than trying to learn a piece at a time through Google-- so get a jump-start now and become the Web API expert on your team!
The Experience
The course experience is intended to feel like a more intimate, one-on-one setting. I want you to feel like you and I are both sitting down in front of your computer, reviewing some code in Visual Studio and having a friendly discussion about how things work, the pros and cons of a technique, and practical issues you might face when you start writing your own services using the framework.
The goal is not just to learn about the details of Web API. The examples and assignments are designed to create a web service mindset and give you of ways of thinking about the construction, performance and deployment of your web services, especially in scenarios that have unique cross-platform integration requirements.
The Tech Stack
This course specifically uses the standard .NET Framework version of Web API, which usually runs under IIS on Windows servers. If you are using .NET Core instead of .NET Framework, then while the concepts in this course are similar, the specific syntax for .NET Core Web API is very different. This probably isn't the course for you if you are specifically targeting .NET Core.
For testing, we'll be using Fiddler, PostMan and Swagger (via the Swashbuckle library).
Real World Focus
My "Real World" courses specifically target working developers solving actual problems in typical business programming scenarios. They are uniquely designed to cover areas you don't find in other courses on similar topics, from the specific viewpoint of developers who need to translate theory into practical application to solve the kinds of problems the "overview" courses don't help with. I assume you already know how to program and have built working commercial systems-- you won't find any "Hello, world" here!