Tag: General
All the articles with the tag "General".
-
Help, I've inherited an ASP.NET MVC Core code base with no Cross-Site Request Forgery (CSRF) measures!
As ASP.NET MVC developers, whether ASP.NET MVC 5 or ASP.NET MVC Core, we all know it is important to perform certain validations to prevent a Cross-Site Request Forgery (CSRF) attack against the application we are building. The ASP.NET MVC provides the @Html.AntiForgeryToken() helper which we can use to add a hidden field in the form we are posting, and a [ValidateAntiForgeryToken] attribute which we can decorate our action method with and instructs the framework to validate the posted token is valid (or was forged).
-
Registering a type as an interface and as self with ASP.NET Core dependency injection
While I am a big fan of Autofac to serve as the framework for making Inversion of Control (IoC) and Dependency Injection (DI) work in an application, it is quite convenient in simple projects to use the built-in dependency injection in ASP.NET Core. While simple to replace the default one with Autofac, the default one is often sufficient. Unless it’s not! Consider the following component registration: With the default Microsoft.Extensions.DependencyInjection package in ASP.NET Core, we can now consume an ICustomerService in, for example, our controllers:
-
How to become a remote worker
Yes, it’s 2018, us IT folks have probably been working remote for quite a while (full-time or occasionally), but there are other industries where these things take time. Not to mention that in countries like Belgium, remote work also has to be arranged for in employment contracts or ancillary documents. But anyway, I digress.
-
How HTTP Chunked Encoding was killing a request
Recently, someone asked me to look at their ASP.NET MVC application and help figure out why a certain request was taking 16 seconds to complete. It’s always fun to look at those things, so I could not pass on this nerd snipe. Much like with hunting serial killers, you have to become one with the scene at hand. Watch the crime scene. Look at the things that happen, and observe. How can you observe a web application? The browser is a good start. Since this specific call was returning JSON data, I thought it easier to look at it in Fiddler instead. A typical response looked like this:
-
Remote debugging of Node.js apps on Azure App Service from WebStorm
At Microsoft Build 2018, a number of Azure App Service on Linux enhancements were announced. One that I was interested in was this one: Remote debugging, in public preview: You can now choose to remote debug your Node.JS applications running on App Service on Linux. Sweet! But… how? The blog post did not mention a lot of details on the debugging part, so let’s walk through it, shall we? Remote debugging of Node.js apps on Azure App Service from WebStorm! First of all, we will need a number of things on our machine: The latest version of the Azure CLI 2.0
-
Retiring as a Microsoft MVP
I have decided to retire from the Microsoft MVP program. In the first week of April, an e-mail from Microsoft landed in my mailbox. I was given the choice to either remain an active MVP (but without access to NDA content) until my next renewal period, or retire from the program.
-
Running Kotlin in Azure Functions
A while back, the Azure folks announced support for Java on Azure Functions. My immediate thought was: “Do they mean Java or JVM? And if they mean JVM, will it work with Kotlin?” In this blog post, we’ll find out! (and if you’re a .NET developer, you’ll learn a bit about that other platform: the JVM) Azure Functions are Microsoft Azure’s event-driven, serverless compute experience. That’s all the buzzwords, probably, but it boils down to not having to worry about virtual machines, sites, …
-
Using operator overloads for concatenating file system paths in CSharp
The past few days, I’ve been working on some cross-platform C# code. In this code, I needed to build a path to a file, by concatenating folder names. As you may know the path separator on Windows and Linux operating systems are different: one has a backward slash (\), the other has a forward slash (/). Luckily for me, the .NET framework(s) contain a utility function for this: Path.Combine handles this for me! Here’s an example: This will generate a platform-specific path: Great! However, I found something else in the codebase I was working on (ReSharper):
-
On speaker life...
Last week, I did a tweet while at the Paris Charles de Gaulle airport, working on blog posts (part of my job) and drinking bad coffee. The backstory is I just finished a week of conference and speaking (Microsoft Experiences Paris, JetBrains Night Paris) and there is of course some real work to be done in between all the “glamour” of public speaking. Many people I talk with at user groups or conferences sometimes feel speakers at conferences are special and rockstars and have glamourous lifes. In this post I want to touch on that, and also on a reply I got to my tweet:
-
Building a scheduled task in ASP.NET Core/Standard 2.0
In this post, we’ll look at writing a simple system for scheduling tasks in ASP.NET Core 2.0. That’s quite a big claim, so I want to add a disclaimer: this system is mainly meant to populate data in our application’s cache in the background, although it can probably be used for other things as well. It builds on the ASP.NET Core 2.0 IHostedService interface. Before we dive in, I want to give some of the background about why I thought of writing this.