Tag Archives: ASP.NET Core

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

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

Middleware in ASP.Net Core – part I

Published by:

Middleware is a very important topic in ASP.Net Core since it enables you to add very important functionality, like adding necessary configuration to deploy ASP.Net Core and Angular together. But at the same time there are a lot of misunderstandings regarding middleware in ASP.Net Core among developers that are new to the platform. That’s why I think it’s a good start to highlight the most important concepts regarding middleware so that new developers can get started much quicker with ASP.Net Core.

The concept of middleware

I won’t try to give a real and exhaustive definition of middleware (you can find this on the Microsoft documentation). Instead, I will try to depict a picture of how middleware in ASP.Net cor relate to the application you’re developing. So let’s imagine that you already have an ASP.Net Core application that is hosted somewhere and I want to make a request to that application. So when I send my GET request, it will first hit Kestrel, the web server built into ASP.Net Core. For the request, that’s the entry point to the application. Continue reading

Deploy ASP.Net Core back end with Angular front end

Published by:

Single page applications (SPA) have become a standard in the web development world by now, reshaping the way web applications are designed. Traditionally a web browser (client) would send out a GET request to a server and the server would return an HTML page. Nowadays we have SPAs that rely on web APIs for data retrieval and that run like real applications in a browser. That’s why in the .Net ecosystem having¬†¬†.Net Core web APIs with Angular 2+ front end is a common scenario and it might be useful to look into different basic deployment strategies. Before I go any further, I want to point out that this article is aimed for junior developers, developers that are new to the .Net ecosystem or for all those that are on their way to become software developers. Continue reading

Building SPAs with C#

Published by:

Looking at this title, many developers would say “Are you mad? You can’t build single page applications with C#! You need a front end framework, like Angular, React or Vue”. Right now I can’t say that I can prove them wrong, but I can definitely at least say that building SPAs with C# is in fact possible. For now it’s only experimental, but the ASP.NET team announced an experimental project called Blazor.¬†Blazor is an experimental web UI framework based on C#, Razor, and HTML that runs completely in the browser via WebAssembly. This really opens new perspectives on the fact that you may build modern SPAs using C# and the entire .NET stack.¬† Continue reading

Databases for modern web applications

Published by:

Databases are one of the first things to think about when developing new software, especially web applications. I know that at a first sight, this topic seems to be a little odd: you simply use a relational database like SQL or MySQL ant that’s it, right? Well, I think that modern web applications are a little bit more complex and it might be worth considering other options and that’s why I would like to tackle this topic.

Traditional relational databases are clearly a goo fit for static applications. By static I think about applications that don’t change very often or that don’t require a huge amount of read and write operations. For example, if I would like to build my own blog at a certain time, I would surely choose SQL. And if I think about the data model for a blog post, it could be designed as something like this: Continue reading