Quantcast
Channel: Web Api – no dogma blog
Browsing all 26 articles
Browse latest View live

ASP.NET 5 Web Api Controller with multiple get methods

I have two other posts on multiple GET methods, both for Web Api 2, the first shows how to use routes like ‘http://…/api/values/geta’ and the second shows ‘http://…/api/values/22’ or...

View Article



Web API 2 and ninject, how to make them work together

Full source code to download. I’ve been using ninject for a few years, but every time I use it with Web Api I hit some problem and they usually stem from not including the right nuget packages, not...

View Article

Image may be NSFW.
Clik here to view.

Getting Web API Exception Details from a HttpResponseMessage

The Problem It’s hard to get the details of an exception from a Web Api response when calling Web Api from a C# program. (Skip to the solution if you don’t care about the background), it even handles...

View Article

Web API 2 Controller with multiple get methods

I have two other posts on multiple GET methods, one for ASP.NET 5 Web Api, and another for Web Api 2. It seems that every version of Web API changes how it handles default routes or route prefixes or...

View Article

Fluent Validation with Web Api 2

Full source code here. I wrote blog post in 2015 on using the Fluent Validation NuGet package for complex validation needs. In the post the validator checked that a create person request had at least...

View Article


Downloading an in-memory file using Web Api 2

Download full source code At first you think it’s going to be easy to download a file from Web Api, but as I discovered, it was not. In my case I wanted to load data from the database, perform some...

View Article

Web API 2 Controller with multiple GET methods – part 2

I have two other posts on multiple GET methods, one for ASP.NET 5 Web Api, and another for Web Api 2. Download full source code. A few months ago I wrote a post explaining how to create a controller...

View Article

Image may be NSFW.
Clik here to view.

Web Api 2 Without MVC

Download full source code. When building a Web Api 2 application there is much unneeded MVC baggage that comes along with it. To start with all the css, html and javascript can go, then most of the...

View Article


A simple Polly example with WebApi 2

Download full source code. If you are calling APIs and you haven’t heard about The Polly Project, you should check it out. It helps take care of many common problems like unreliable connections,...

View Article


Reusing Polly Policies with Dependency Injection

Download full source code. In my previous post “A simple Polly example with WebApi 2” I showed how to make a request to an unreliable endpoint protected by a Polly retry policy. For more on Polly see...

View Article

Letting a request fail with Polly

Polly is fantastic for transparently retrying a request but there is always a point at which you must give up. Here you have a choice, let the request fail and inform the original caller or use the...

View Article

Re-authorization and onRetry with Polly

Full source code available here. In a previous post I showed how to use Polly to make a simple call, retrying in the event of failure. In another I showed how to let a request fail and process the...

View Article

Returning default values from a failed web request with Polly Fallbacks

Full source code available here. In previous posts on Polly I showed how to use a simple retry, and a retry with a delegate that is called before the request is retried. In this post I will show how...

View Article


Fluent Validation in ASP.NET Core

Full source code available here. I have written about Fluent Validation a couple of times. There is a new library available for .Net Core. How to return to validation messages back to the caller is not...

View Article

.NET Core Web Api Routing

Full source code available here. Routing in .NET Core Web Api (1.1 and 2) is a little different than in earlier versions. I’ve written about this a few times, you can find those posts here. In this...

View Article


.Net Core Multiple Get Methods with the Action Method Selector Attribute

Full source code available here. In .Net Core Web Api it is not possible for the routing mechanism to distinguish between the following action methods. public string GetSomething(int id, int something)...

View Article

Image may be NSFW.
Clik here to view.

Unit Testing .NET Core 2 Web Api

Full source code available here. Unit testing Web API controllers in .NET Core 2 is very easy. I have very simple GET and POST methods. [Route("api/[controller]")] public class ValuesController :...

View Article


Entity Framework Core 2 Unit Testing in .NET Core 2

Full source code available here. Unit testing Entity Framework used to be quite a chore, but over the past few years it has become significantly easier. In this post I’m going to show you how to use...

View Article

HttpContent ReadAsAsync with .NET Core 2

Full source code available here. If you are used to using HttpContent.ReadAsAsync you might be surprised to learn that it is missing from .NET Core 2. You can try adding Microsoft.AspNet.WebApi.Client...

View Article

Reusing HttpClient with Dependency Injection

Full source code available here. If you are using HttpClient to make requests for you, you might have come across some articles discussing how to reuse HttpClient. They strongly advocate for using a...

View Article
Browsing all 26 articles
Browse latest View live




Latest Images