Development With A Dot
Blog on development in general, and specifically on .NET. Created and maintained by Ricardo Peres.
-
.NET 8 Dependency Injection Changes: Keyed Services
It has been quite some time since my last post on dependency injection (DI). In it I tried to talk a bit about the history of DI (or dependency resolution); now, a change is about to come in .NET 8: named (or keyed) services! Essentially, it consists of the possibility to register multiple times the same type under different names, and to inject a specific type/name combo.
-
Implementing React's UseState in C#
It's been a long time since my last post! Well, I'll try to change that. For now, I'll just leave something I was playing with: an implementation in C# of React's UseState function (or hook, in React terminology). This is merely for fun, but, hey, who knows if it might help someone!
-
Current Limitations of Entity Framework Core
Although EF Core seems to be the most popular ORM in the .NET world in these days – and I for sure won’t contradict it –, there are still some functionality missing, specially if we compare it with other ORMs that also exist, NHibernate coming obviously to my mind. This post is a reflection about that, it is in no way a comparison with other ORMs, in particular, NHibernate, it’s more a wish list for EF Core. I still follow and love NHibernate, and it’s still, in many ways, way ahead of EF Core, but that’s not what I’ll be writing about.
-
Using Generated Methods Instead of Reflection
It is a common thing to say that reflection is slow.You will find tons of posts saying this, and I generally tend to agree to them, although in most cases we generally don’t need to care that much – in fact, so many libraries and frameworks that we rely on daily depend on it!
-
Changing Schema Dynamically in EF Core
Sometimes it may be necessary to change the schema for some entities based upon some criteria. This may be because of multitenancy or because you want to test something and don’t want to pollute the main schema. Here is a possible solution, going directly to the annotations that EF Core uses.
-
Posting AJAX Requests to ASP.NET Core MVC
In the past, I’ve had trouble doing something that is apparently simple: invoking a simple action method in a controller using AJAX. Although it is indeed simple, when using jQuery, it may require some attention, hence this post.
-
ASP.NET Core Pitfalls – Null Models in Post Requests
Sometimes, when AJAX posting to a controller, you may get a null model. Why?
-
ASP.NET Core Pitfalls – AJAX Requests and XSRF
When using Anti Cross Site Scripting Forgery (XSRF) protection in your application, which is on by default, you may be surprised when you try to AJAX submit to a controller and you get a HTTP 400 Bad Request: this may be happening because the framework is blocking your request due to XSRF.
-
ASP.NET Core Pitfalls – Async File Uploads
When performing file upload(s) to an asynchronous action, it may happen that the uploaded file(s) may not be accessible, resulting in an ObjectDisposedException. This is because the uploaded files are saved to the filesystem temporarily by ASP.NET Core and then removed, after the request has been processed, which is generally what we want. If we issue an asynchronous task with an uploaded file and don’t wait for it to finish, it may happen that it occurs outside of the request’s scope, meaning, the uploaded file is already gone.
-
Inline Images with ASP.NET Core
The most common way to show an image in an HTML page is to use the <img> tag to load an external resource. Another option is to use a URL that is a Base64 encoded version of the image. There are some aspects worth considering: