How to integrate Ocelot with Identity Server 4

Published by:

Not so long ago I wrote an article on how we can create our own API gateways using the Ocelot open source library. Since then, I received some questions on how to integrate Ocelot with Identity Server 4 so I thought to share how I managed to achieve this using the Ocelot documentation and some basic Identity Server 4 knowledge. Please note that following these steps I was able to successfully build an API gateway using Ocelot, that used Identity Server 4 JWT tokens to authorize requests and redirect them to the desired downstream path. Continue reading

New Asp.Net Core 2.1 features announced at #MsBuild

Published by:

Last week #MsBuild was underway in Seattle. I have already made some notes on the keynote last Monday and the following days I tried to keep track with different novelties announced for ASP.Net Core 2.1. And I think for some members of the community it might be useful to have them written down, so in this article I’ll try to summarize all the information. Please note, that I was not present at the #MsBuild conference. I just tried to follow the sessions streamed on Channel 9 and some key Twitter accounts.

HttpClientFactory

One of the novelties I am most exciting about is the new HttpClientFactory feature. If you worked with the HttpClient in production software, there is a good chance that you noticed a lot of challenges and head aches. In a services oriented architecture where we might need to have several different connections, the only way to go is to use several HttpClient instances (sure not for every call a new client ūüôā but still a bunch of them).¬† One of the problems is that each HttpClient would maintain its own connection pool to the remote server, so it’s highly inefficient. The second, and most stringent problem, is that in scenarios where an application needs to make a lot of calls to remote servers, you could exhaust all the available sockets from time to time. And this is really not cool at all.¬† Continue reading

Microsoft Build 2018 keynote summary

Published by:

The Microsoft Build 2018 kicked off today in Seattle with Microsoft CEO Satya Nadella taking the stage and presenting Microsoft’s vision and strategy for the developer ecosystem. Scott Guthrie took then the audience through the main technical novelties with a lot of help from product managers and Microsoft partners or customers. If you missed the Microsoft Build 2018 keynote, here is a brief summary of what happened, taking note that it might be difficult to sum up in a few lines everything that was discussed for more than 3 hours.¬† Continue reading

Building your own ASP.Net Core API gateway with Ocelot

Published by:

I’m currently working on some very interesting stuff and one of it is building an Asp.Net Core API gateway. An API gateway might be a very useful part in a service oriented architecture using the micro services approach. In such an architecture you might have a lot of different APIs, each responsible only for one specific thing. Without an API gateway, consumers would need to send requests to each API and then aggregate the responses. An API gateway would do exactly this for the consumers (and many more of course) so that they would need to send only one request to one endpoint and the gateway would aggregate the needed response. Continue reading

The quest for a perfect IDaaS solution

Published by:

Every discussion about security should start with a discussion about identity and access management. It’s that important and therefore the quest for a perfect IDaaS solution is a painful but needed journey. One could of course choose to build its own identity and access management systems/software, but most of the time companies don’t have the necessary time and resources to do that since we’re seeing crazy release cycles nowadays. Going towards IDaaS is therefore a natural choice in a lot of circumstances. But do we really have a “perfect for every scenario” IDaaS solution somewhere out there? Let’s see! Continue reading

The curious case of strings in C#

Published by:

In the last article I tried to describe the difference between value types and reference types in C# and I received some interesting feedback from colleagues and former colleagues as well. And based on discussions I had, it makes a lot of sense to talk a little bit about strings. Strings are very strange, because they are a reference type but behave somehow similar to value types. So, there are some common misconceptions and misunderstanding when it comes to strings that I will try to clarify in this article.

Note: I have also created a video on this topic. If you find it easier to follow the video, then here it is:

Continue reading

Reference types and value types in .NET

Published by:

In .NET (and therefore C#) there are two main sorts of type: reference types and value types! Understanding these sorts of type is crucial in the .Net ecosystem and, more generally, in object oriented programming. There are some clear definitions of these concepts that anybody could learn fairly easy, but really understanding how reference types and value types work is sometimes a little bit harder. And I must confess that it took me some time to achieve a certain level of familiarity. Furthermore, if you really want to understand how reference types and value types work, you need to get your hands dirty an play around with them. In this article I will try to explain reference types and value types as good as I can, starting from some dry (but important) definitions that I will try to make more vivid using code samples.

Note: I also made a YouTube video on this topic with some more graphical representations of these concepts. You might want to check it out:

Continue reading

Sorting lists in C#

Published by:

Working with lists is something developers do almost everyday. One of the most common tasks when we think about lists is sorting them. Fortunately, sorting lists in C# is not very complicated when it comes to primitive types and strings, but are slightly more complicated when we create lists of our own objects. In this tutorial we’ll go through some of the common ways to sort lists in C#.

Update:¬†I have also created a video on this topic so if you think that it’s easier to follow the video, here it is:

Let’s start with a short and simple example. Let’s assume that we create a list of names and we add some names to the list:


List<string> names = new List<string>();
names.Add("John");
names.Add("Dan");
names.Add("Zack");
names.Add("Cristina");

Continue reading

Middleware in ASP.Net Core – part II

Published by:

Few days ago I wrote a short tutorial about middleware in ASP.Net Core and I promised to continue the topic, since there are some concepts that I didn’t cover. In the mentioned first tutorial I tried to describe what a middleware pipeline is, why middleware order is important and the importance of the¬†next()¬†delegate. In the second part I will focus more on the¬†Use(),¬†Run() and¬†Map() methods that we can use when setting up the middleware pipeline of an ASP.Net Core application.

Technically speaking¬†Use(),¬†Run() and¬†Map()¬†are extension methods on¬†Microsoft.AspNetCore.Builder.IApplicationBuilder instances. If you look them up, you’ll see something like this: Continue reading

Thoughts about Cambridge Analytica

Published by:

There’s a huge scandal these days around Cambridge Analytica since¬†The New York Times and The Observer reported on the company’s use of personal information acquired by an external researcher who claimed to be collecting it for academic purposes. In response, Facebook banned Cambridge Analytica from advertising on its platform. Reports also say that Cambridge Analytica¬†CA worked for¬†Donald Trump’s presidential campaign. That’s just to draw the context. As a last introduction note, I won’t make any comment on politics or legal aspects of this scandal! Continue reading