
Image by awcreativeut
MVC Filters are discussed in detail at docs.microsoft.com
Filters in ASP.NET Core allow code to run before or after specific stages in the request processing pipeline.
Image by awcreativeut
MVC Filters are discussed in detail at docs.microsoft.com
Filters in ASP.NET Core allow code to run before or after specific stages in the request processing pipeline.
Image by awcreativeut
CORS are best described on MDN
Cross-Origin Resource Sharing (CORS) is an HTTP-header based mechanism that allows a server to indicate any origins (domain, scheme, or port) other than its own from which a browser should permit loading resources. CORS also relies on a mechanism by which browsers make a "preflight" request to the server hosting the cross-origin resource, in order to check that the server will permit the actual request. In that preflight, the browser sends headers that indicate the HTTP method and headers that will be used in the actual request.
CORS in .NET6 API can be configured using CORS policies.
Image by awcreativeut
A blog post is in progress.
A Channel by merriam-webster refers to among other meaings
the bed where a natural stream of water runs
I will start this post by adopting the water channel analogy to explore how it relates with C# System.Threading.Channels
.
Records - A Reference Type were introduced in C#9 and extended in C#10 to allow record struct - A Value Type. What is so special about records that the .NET team shipped them in two consecutive releases. In nutshell C# lacked a immutable type with true value equality semantics with a short syntax. Records solves this problem. In this post you will learn:
Does this make you curious? I am excited to share this with you.
I have recorded a detailed Youtube video, if you prefer the video content.
Image by JetBrains Linkedin
The refactoring of legacy applications is the most valuable skill, you must continuously learn. The ASP.NET Framework 4.x applications are considered legacy, and the dependency injection was not part of the framework. In recent survey done by JetBrains on Linkedin, 46% developers voted the legacy applications as their biggest challenge. In this blog post, you will learn how to incrementally enable DI in ASP.NET 4.8 Web Api application which does not use any sort of DI mechanism, not even poor man DI.
Image by @claybanks
I am working on migrating the .NET Framework application to the .NET6. Since the application was initially written in the .NET Framework 2.0 thus it contains the legacy approaches to get the data from the database. We were using the old version of Microsoft Enterprise Library Data Access package to get the data from the database which is not compatible with the .NET Standard 2.0. So I decided to generate the code for stored procedures using the Dapper and Handlebars templates.
I faced two problems:
Image by @claybanks
Authorizing the resource access is essential part of any API. The .NET provides you a perfect mental model which is easier to reason about. It has this flow:
IAuthorizationRequirement
interface.AuthorizationHandler<UniqueIdHeaderRequirement>
and register it.Then Authorize
attribute allows you to set a policy name when used on controller or action method.
But if you are fan of Minimal API then fluent style is the way to go using RequireAuthorization
.
When the application expects Unicode characters as input from the user, it is best to normalize it before storing it in the database, especially when you plan to use the information for comparison.
Suppose the application asks the user to upload a file with the same name as their first name, which contains the character é. If you validate the file name using the string comparison (===) operator or comparing length, it will fail if different Unicode code points represent the input.
You validate the client-side and server-side using C# as a best practice. It would be best to normalize the string before comparing; otherwise, the validation will fail either at the server or client side.
Browser's behavior is different for the Unicode characters; some do the normalization, and some do not. I recently had to fix an issue where string comparison without normalization only failed when the user uploaded the file using Chrome or Firefox on Mac. One such example is on here.
Some unicode character like ñ can be represented by using one code point (\u00F1) or two code points (\u006E\u0303). Such characters visually looks exactly the same but will have different string length. Thus string equality comparison and length tests will fail. This MDN and .NET article(s) describe it beautifully. If you are expecting unicode characters as an input from the user, store it after normalizing.
Variance means change. The concept of change applies to reference types of objects in C#. Behavior changes in objects are observable in two ways:
Exposing the simplistic interface of anything complex is a Facade. For example, when you place an order for Pizza delivery, the application hides the complex process behind Pizza Delivery to your door.