James Flower

.NET Developer working on the web and cloud

AI Assistance for Software Developer Productivity – The Good, The Bad & The Ugly

Posted on
5 min read

Software Development can have moments of writing repetitive code. Following the DRY principle can help avoid this, but sometimes one block of code isn’t doing the same thing as another, although it is doing something similar (such as mapping objects in a collection). In these cases AI can be a helpful aid, but it does have drawbacks too! The Good – AI Accelerated Development Artificial Intelligence and Machine Learning have been applied to these kinds of problems for a while, and n

Read more...

Using ngrok with IIS Express and ASP.NET Core

Posted on
3 min read

Sometimes it can be helpful to quickly make the version of a project which is running on your development machine available to others. This could be for webhook integrations, demos, or some other reason. One of the tools you can use to achieve this is ngrok. ngrok creates a secure tunnel and expose the web server running on your machine (usually IIS Express for .NET Projects if you’re working on Windows). As a result, you can give a publicly accessible URL (such as https://a1c2e3g4i5kl.n

Read more...

Microsoft Remote Desktop (RDP) Stuck on "Please Wait"

Posted on
2 min read

I often use Remote Desktop Connection (RDP) to connect to computers remotely when I am out and about. However, recently when I tried to remotely connect using RDP, I became stuck at a blue screen with a “Please Wait” message after connecting. After a few minutes of waiting, I became a bit suspicious that something wasn’t working correctly, especially since I was using the connection just fine a few hours before. Below are some of the solutions I’ve found that may work if you find yo

Read more...

Logging in .NET Core using ILogger

Posted on
4 min read

Logging is an important part of software development. It helps us know that tasks have been completed, monitor applications and provides a trail to follow when things don’t work. Microsoft has included a logging framework in .NET Core and ASP.NET Core to allow developers to easily implement logging and choose their own logging provider (this is the part which decides how to store your log messages). A good logging solution can be invaluable when an application stops working as expec

Read more...

Using a Vue.js SPA with ASP.NET Core Web API

Posted on
9 min read

I recently started working on a new side project and decided to implement it as a single page application (SPA). For this, I chose to build an API powered by an ASP.NET Core Web API and a Vue.js powered front-end to consume the API. I could find templates included in Visual Studio for AngularJS and React but nothing for Vue.js. Since I already have experience with Vue.js I decided to document the steps I used to create my starter project from a blank ASP.NET Core web app using ASP.NET Co

Read more...

Handling null values in C#

Posted on
4 min read

Handling null values in C# and .NET comes with the territory. Null values were introduced by Tony Hoare in mid-1960s to represent missing or unknown data. This is a useful capability but it has resulted in null reference exceptions becoming one of the most common causes of bugs which developers face. As a result, Tony Hoare now calls the null reference the ‘billion dollar mistake’. C# has always allowed reference types to be nullable, and as a result, the NullReferenceException is someth

Read more...

What makes a good log message?

Posted on
5 min read

Logging can provide important information about the behaviour of software applications. It allows operations staff to monitor application performance and gives developers a trail to follow when trying to diagnose the cause of errors. With this in mind, it is worth considering what is good information to record in a log file and what format it should be recorded in. Below is a list of the general guidelines I follow when writing log messages. Use log levels to indicate severity

Read more...

How to send emails in .NET Core with MimeKit and Mailkit

Posted on
3 min read

The ability for an application to send emails is a very common requirement. This can be for emails such as providing account information, sending marketing emails or even a password reset email. This post will cover how to send an email using MimeKit and MailKit from an ASP.NET Core MVC web application. I will use MailSlurper as a local SMTP server to test the sending of the emails. You can use any SMTP server you prefer though. Creating the ASP.NET Core MVC demo project

Read more...

Changing Query String values in ASP.NET MVC

Posted on
2 min read

Recently I was trying to update a query string by adding or updating a parameter for URLs generated in a partial view. I found an excellent example for achieving this by setting route data here however this didn’t preserve current query string values in the URL. I’ve extended upon that code and updated it to include the query string values in the route data which will be appended to the query string in the generated URL (assuming the parameter key doesn’t match part of the route). p

Read more...

Disabling an ASP.NET MVC input control

Posted on
2 min read

I love ASP.NET MVC. It is a great framework to get web apps quickly built. However using the built in HtmlHelper methods on your views isn’t without its issues. An example of this is when trying to disable a HTML input control which has been built using HtmlHelper. You can add the “disabled” attribute which would be required by making use of one of the helper’s overloads however if you want to conditionally disable a control (based on your view model) it can result in your view’s code be

Read more...