Blog - C#

Swimburger
.NET logo

Change the ServiceLifetime after the service has been added to the .NET ServiceCollection

- .NET
Learn how to change the lifetime of services already added to a service collection.

How to build a URL Shortener with C# .NET and Redis

- .NET
Learn how to build a link shortener using C#, .NET, and Redis. You'll be using ASP.NET Core to build the URL forwarder and the System.CommandLine libraries to manage the data.
Generate TwiML using Strings in C#

How to generate TwiML using Strings in C#

- .NET
Learn how Twilio uses webhooks and TwiML to give you control over how to respond to a call or text message. You can generate TwiML using strings in many ways, and with C# 11 you can now also use Raw String Literals.
Use Raw String Literals to generate TwiML in C# 11

Use Raw String Literals to generate TwiML in C# 11

- .NET
Learn how Twilio uses webhooks and TwiML to give you control over how to respond to a call or text message. You can generate TwiML in many ways, and with C# 11 you can now also use Raw String Literals.

Use Visual Studio dev tunnels to handle Twilio Webhooks

- .NET
Learn how to develop webhooks on your local machine using Visual Studio dev tunnels and ASP.NET Core.
Visual Basic logo

How to create an ASP.NET Core Minimal API with Visual Basic .NET (there's no template)

- .NET
Visual Basic .NET (VB) is not dead, but it's not getting the same amount of love as C# or even F#. Luckily, all that is .NET can be used by all .NET languages including VB, so you can still use ASP.NET Core and Minimal APIs with the VB language.
Conversation between an iPhone user and the SMS bot. The user says "Hi" and the bot responds with "Welcome to the U.S. Representative lookup bot. Respond with your address. The user sends an address and the bot responds with "Your representative is Gerald E. Connolly (Democratic Party) representing Virginia"s 11th congressional district. Then the bot sends an image of the representative.

Find your US Representatives and Congressional Districts with SMS and ASP.NET Core

- .NET
Learn how to create an SMS bot that looks up U.S. Congressional Districts and Representatives using the Google Civic Information API, C#, ASP.NET Core Minimal API, and Twilio SMS.
.NET bot flying with a jetpack

How to Bulk Email with C# and .NET: Zero to Hero

- .NET
There are many ways to bulk email, each with their own strengths. Learn how to bulk email with C# and .NET using SendGrid.

Provide default configuration to your .NET applications

- .NET
Learn how to provide default options into your .NET configuration to reduce redundancy
Twilio logo

How to better configure C# and .NET applications for SendGrid

- .NET
Learn how to configure your .NET applications better for sending SendGrid emails
.NET Bot holding a browser URL bar and a toolbox

How to get the full public URL of ASP.NET Core

- .NET
Learn how to get the public full URL of your ASP.NET Core application
.NET Bot holding a browser URL bar and a toolbox

How to generate absolute URLs in ASP.NET Core

- .NET
Learn how to generate full absolute URLs in C# and ASP.NET Core web applications.
Twilio logo

How to better configure C# and .NET applications for Twilio

- .NET
Learn how to use multiple configuration sources, strongly-typed objects, and implement the options pattern in your .NET applications
.NET Bot holding a phone and bag with the Twilio logo

What's new in the Twilio helper library for ASP.NET (v5.73.0 - April 2022)

- .NET
Learn about what's new and old with the Twilio helper library for ASP.NET in version 5.73.0
Twilio logo

How to Send SMS without a Phone Number using C# .NET and an Alphanumeric Sender ID

- .NET
You don't always need a phone number to send SMS! Learn how to send text messages using Alphanumeric Sender IDs.
How to prevent Email HTML injection in C# and .NET

How to prevent email HTML injection in C# and .NET

- .NET
Learn how bad actors can inject HTML into your emails in your C# .NET applications and how to mitigate it.
Twilio SendGrid logo

How to send ASP.NET Core Identity emails with Twilio SendGrid

- .NET
Learn how to use SendGrid to send account verification and password recovery emails in ASP.NET Core
Twilio SendGrid logo

How to send Email in C# .NET using SMTP and SendGrid

- .NET
You can use the SendGrid APIs to send emails, but you can also use SMTP with SendGrid. Learn how to send emails using SMTP, SendGrid C# .NET
Twilio logo

Send Scheduled SMS with C# .NET and Twilio Programmable Messaging

- .NET
Learn how to schedule SMS with C# .NET and Twilio Messaging's latest feature: Scheduled Messaging!
.NET Bot

How to get ASP.NET Core's local server URLs

- .NET
Learn how to access the ASP.NET Core's local server URLs in Program.cs, in controllers using Dependency Injection, and in IHostedService or BackgroundService.
Twilio SendGrid logo

How to send recurring emails in C# .NET using SendGrid and Quartz.NET

- .NET
Learn how to send recurring emails with C# .NET using Quartz.NET and SendGrid's APIs
Twilio SendGrid logo

Send Emails using the SendGrid API with .NET 6 and C#

- .NET
Learn how to send emails using the SendGrid API with a .NET 6 console application and C#
.NET bot writing on whitebpard

Generic Linear Search/Sequential Search for a sequence in C# .NET

- .NET
To practice algorithms and data structures, I reimplemented Linear Search/Sequential Search for a sequence using C#'s generic type parameters.
.NET bot writing on whitebpard

Generic Boyer–Moore–Horspool algorithm in C# .NET

- .NET
To practice algorithms and data structures, I reimplemented Boyer–Moore–Horspool algorithm for a sequence using C#'s generic type parameters.
.NET bot writing on whitebpard

Generic Binary Search in C# .NET

- .NET
To practice algorithms and data structures, I reimplemented binary search using C#'s generic type parameters.
.NET bot writing on whitebpard

Generic Insertion Sort in C# .NET

- .NET
To practice algorithms and data structures, I reimplemented insertion sort using C#'s generic type parameters.
.NET bot writing on whitebpard

Generic Quick Sort in C# .NET

- .NET
To practice algorithms and data structures, I reimplemented Quick Sort using C#'s generic type parameters.
.NET bot writing on whitebpard

Generic Merge Sort in C# .NET

- .NET
To practice algorithms and data structures, I reimplemented merge sort using C#'s generic type parameters.
.NET bot writing on whitebpard

Generic Bubble Sort in C# .NET

- .NET
To practice algorithms and data structures, I reimplemented bubble sort using C#'s generic type parameters.
C# and Chrome logo

Download the right ChromeDriver version & keep it up to date on Windows/Linux/macOS using C# .NET

- .NET
Chrome frequently updates automatically causing ChromeDriver versions to mismatch. Using C# .NET you can download the correct version of the ChromeDriver and keep it up-to-date.
An illustration of a lock and a key. The key handle is in the shape of the Twilio logo.

Better Authentication with Twilio API Keys

- .NET
API Keys are now the preferred way to authenticate with Twilio's API. You can create as many API Keys as you need and remove them if they are compromised or no longer used.
.NET Bot building an application

Use project Tye to host Blazor WASM and ASP.NET Web API on a single origin to avoid CORS

- .NET
Using Microsoft's experimental Project Tye, you configured the proxy to forward requests to '/api' to the Web API, and all other requests to the Blazor WASM client.
.NET Bot building an application

Use YARP to host client and API server on a single origin to avoid CORS

- .NET
Using Microsoft's new reverse proxy "YARP", you configured the proxy to forward requests to '/api' to the Web API, and all other requests to the Blazor WASM client.
 Blazor logo next to an arrow pointing to the GitHub logo next to a double arrow pointing from the GitHub logo to the Firebase Hosting logo

How to deploy Blazor WebAssembly to Firebase Hosting

- .NET
With ASP.NET Blazor WebAssembly you can create .NET applications that run completely inside of the browser. The output of a Blazor WASM project are all static files. You can deploy these applications to various static site hosts like Firebase Hosting.
Blazor next to JavaScript logo

Interacting with JavaScript Objects using the new IJSObjectReference in Blazor

- .NET
A new type is introduced in .NET 5 called IJSObjectReference. This type holds a reference to a JavaScript object and can be used to invoke functions available on that JavaScript object.
.NET Bot

Harden Anti-Forgery Tokens with IAntiforgeryAdditionalDataProvider in ASP.NET Core

- .NET
Using IAntiforgeryAdditionalDataProvider you can harden ASP.NET Core's anti-forgery token feature by adding additional data and validating the additional data.
.NET logo

Rethrowing your exceptions wrong in .NET could erase your stacktrace

- .NET
You may be erasing your stacktrace if you are catching and rethrowing exceptions the wrong way. This could make debugging a nightmare because you don't know where the exception was originally thrown.
NDepend Logo

Checking out NDepend: a static code analysis tool for .NET

- .NET
NDepend is a static code analysis tool (SAST) for .NET. NDepend will analyze your code for code smells, best practices, complexity, dead code, naming conventions, and much more.
DNN Logo

How to add Hangfire to DNN

- .NET
DNN already has an excellent built-in scheduler you can use to schedule tasks. But you may be more familiar with and prefer Hangfire for running background jobs. These instruction will walk you through configuring Hangfire in with DNN.
Screenshot of NCrontab Expression Tester tool

Introducing NCrontab Tester (Blazor WebAssembly)

- .NET
Introducing NCrontab Expression tester, made using NCrontab .NET library, Blazor WebAssembly, and hosted on Azure Static Web Apps
.NET

Download .NET Windows Theme based on the new .NET Brand GitHub repo

- .NET
The .NET GitHub org has a new Brand repository containing a detailed Brand guidelines PDF, logo's, illustrations, and wallpapers. Using these resources I put together a Windows Theme for .NET which you can download here!
.NET Core logo + Dotnet bot wearing Red Hat

How to run ASP.NET Core Web Application as a service on Linux without reverse proxy, no NGINX or Apache

- .NET
This article walks us through running a ASP.NET Core web application on Linux (RHEL) using systemd. The end goal is to serve ASP.NET Core directly via the built-in Kestrel webserver over port 80/443.
.NET Core logo + Dotnet bot wearing Red Hat

How to run a .NET Core console app as a service using Systemd on Linux (RHEL)

- .NET
Let's learn how to run a .NET Core console application on systemd. After running a console app as a service, we'll upgrade to using the dotnet core worker service template designed for long running services/daemons. Lastly, we'll add the systemd package integration.
Phone/Tablet/Laptop displaying Umbraco logo

Implementing Responsive Images in Umbraco

- Umbraco
The web platform has responsive image capabilities such as the srcset-attribute, sizes-attribute, and the picture-element. These capabilities may seem daunting sometimes. We'll learn how to make them available and maintainable to Umbraco content editors.
Visual Studio Code logo cursing at .NET Core logo with Red Hat logo

VS Code C# Extension not working in Remote SSH mode on Red Hat Linux? Here's a workaround

- .NET
Unfortunately, the C# Extension for VS Code malfunctions when following the official steps to install .NET Core on Red Hat and using the Remote SSH extension. OmniSharp is not able to find the .NET Core installation but we can work around this.
Screenshot of the HTML Agility Pack homepage

Auto generate Heading Anchors using HTML AgilityPack DOM Manipulation

- .NET
Manually adding an anchor to every heading would be a painful solution. So let's learn how we can achieve this by generating the Heading Anchors using the HTML AgilityPack .NET library.
.NET and Selenium logo connected to Azure DevOps Pipelines logo driving browser

How to run .NET Core Selenium UI tests on Azure DevOps Pipelines Windows/Ubuntu agents? 🚀

- .NET
his post discusses how to take those UI tests and run them in Azure DevOps Pipelines on both Windows & Ubuntu agents. Use this GitHub repository which contains the UI test project necessary to follow along in this post.
.NET Core + Selenium logo steering a web browser window

How to UI test using Selenium and .NET Core on Windows, Ubuntu, and MacOS

- .NET
Selenium is a browser 🌐 automation tool mainly used for UI testing and automating tasks. Selenium is agnostic of operating system, programming language, and browser. You can automate Chrome on MacOS using C#, FireFox using Python on Windows, or Opera using NodeJS on Linux to give you a few examples.
Azure & .NET & Discord Logo

Creating a Discord Bot using .NET Core and hosting it on Azure App Services

- Azure
Discord is an online communication platform built specifically for gaming. Using .NET Core and Azure App Service WebJobs we can host a Discord bot that can listen and respond to voice and text input.
Robot with Umbraco logo

Crawling through Umbraco with Robots

- Umbraco
The robots.txt file’s main purpose is to tell robots (Google Bot, Bing Bot, etc.) what to index for their search engine, and also what not to. Usually you want most of your website crawled by Google, such as blog posts, product pages, etc., but most websites will have some pages/sections that shouldn’t be indexed or listed in search engines.
Azure Application Insights logo + Umbraco logo

Ignoring Umbraco ping.aspx from Azure Application Insights

- Umbraco
Application Performance Monitors provide you with a lot of data, but some of that data may not be relevant. Specifically, in Umbraco there is a page at \umbraco\ping.aspx that is being called frequently to keep the site alive. This is very useful to prevent the site from "dying" (?), but the data for this request isn't that relevant and could skew your statistics. Using Azure Application Insights ITelemetryProcessor, we can prevent ping request from being sent to Azure Application Insights.
Spider Web with Umbraco logo

Crawling through Umbraco with Sitemaps

- Umbraco
Websites come in all shapes and sizes. Some are fast, some are beautiful, and some are a complete mess. Whether it's a high-quality site is irrelevant if people can’t find it, but search engines are here to help. Though the competition to get on first page is tough, this series will dive into some common practices to make your website crawlable.