Skip to content

Coding Practice

How to Replace Ninject Modules with a IServiceCollection for the ASP.Net DI Container

To my great surprise, I had to realise that the development of Ninject is hardly progressing anymore. I was a huge fan of Ninject and used it for 8 years without any problems. But without any meaningful progress over the last years, I doubt that Ninject is still a good choice for .Net 6 applications. Does it work in .Net 6+? Maybe, but the issues on GitHub do not give me confidence.

Therefore, we decided to minimise our risks and switch to the default dependency injection container in ASP.Net as part of our migration to .Net 6. Microsoft may stop developing that container as well, but at least it should be part of .Net 8.

Turn .Net Project Dependencies Into Python Code With Roslyn

We want to migrate our big application with around 150 projects to .Net 6. To do that, we need to find a sequence to migrate the different projects while we keep their dependencies in place. Otherwise we will have an endless list of problems that prevents us from compiling our code.

Let's combine the power of Roslyn to analyse our Visual Studio solutions with the network algorithms of the Python library NetworkX.

Access your C# Projects Through Code With Roslyn

Roslyn allows us to access our code through code. That permits us to analyse and work with code in a way that was impossible before. In this post we look at the basic parts of working with a Visual Studio solution to figure out what parts make up our application.

The syntax of Roslyn has not changed much in the 5 years since my first experiments. However, the same is not true for the dependencies and the things that work behind the API. Here we need a new combination of Roslyn and its dependencies to explore our solutions through code.

How to Allow Redirects in NWebsec

In one old web application I had to add a redirect form one endpoint to the address of the new application. Everything compiled without a problem, but as soon as I accessed the old address, I got this exception:

NWebsec.Core.Exceptions.RedirectValidationException: A potentially dangerous redirect was detected. Add the destination to the whitelist in configuration if the redirect was intended. Offending redirect: https://my.url.whatever