---
title: "Swimburger - Blog - C#"
description: "Swimburger.net is a blog about .NET, cloud, web development, and whatever comes across Swimburger's plate. Swimburger.net is run by Niels Swimberghe."
canonical: "https://swimburger.net/blog/csharp"
---

[

<picture><img class="blog-post-card__image" src="/cdn-cgi/image/width=250,format=auto,quality=90,height=250,fit=cover/media/5ezl35cf/dotnet-logo.png" srcset="/cdn-cgi/image/width=250,format=auto,quality=90,height=250,fit=cover/media/5ezl35cf/dotnet-logo.png 250w, /cdn-cgi/image/width=375,format=auto,quality=90,height=375,fit=cover/media/5ezl35cf/dotnet-logo.png 375w, /cdn-cgi/image/width=500,format=auto,quality=90,height=500,fit=cover/media/5ezl35cf/dotnet-logo.png 500w" sizes="250px" width="250" height="250" alt=".NET logo" decoding="async" loading="lazy"></picture>

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

3/31/2023 - .NET

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



](/blog/dotnet/change-the-servicelifetime-after-the-service-has-been-added-to-the-net-servicecollection)[

<picture><img class="blog-post-card__image" src="/cdn-cgi/image/width=250,format=auto,quality=90,height=250,fit=cover/media/c3thcerb/e5fgllibudqmqzrhto24l1mwmelv9nvhm2tidiepbro1twidth-1616.png" srcset="/cdn-cgi/image/width=250,format=auto,quality=90,height=250,fit=cover/media/c3thcerb/e5fgllibudqmqzrhto24l1mwmelv9nvhm2tidiepbro1twidth-1616.png 250w, /cdn-cgi/image/width=375,format=auto,quality=90,height=375,fit=cover/media/c3thcerb/e5fgllibudqmqzrhto24l1mwmelv9nvhm2tidiepbro1twidth-1616.png 375w, /cdn-cgi/image/width=500,format=auto,quality=90,height=500,fit=cover/media/c3thcerb/e5fgllibudqmqzrhto24l1mwmelv9nvhm2tidiepbro1twidth-1616.png 500w" sizes="250px" width="250" height="250" alt="Build a URL Shortener with .NET and Redis" decoding="async" loading="lazy"></picture>

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

3/21/2023 - .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.



](/blog/dotnet/how-to-build-a-url-shortener-with-csharp-dotnet-and-redis)[

<picture><img class="blog-post-card__image" src="/cdn-cgi/image/width=250,format=auto,quality=90,height=250,fit=cover/media/g20lioy2/tj9v5o0oobs8fux5ohohkjcuqxnjk-nyjawidth-1616format-png.png" srcset="/cdn-cgi/image/width=250,format=auto,quality=90,height=250,fit=cover/media/g20lioy2/tj9v5o0oobs8fux5ohohkjcuqxnjk-nyjawidth-1616format-png.png 250w, /cdn-cgi/image/width=375,format=auto,quality=90,height=375,fit=cover/media/g20lioy2/tj9v5o0oobs8fux5ohohkjcuqxnjk-nyjawidth-1616format-png.png 375w, /cdn-cgi/image/width=500,format=auto,quality=90,height=500,fit=cover/media/g20lioy2/tj9v5o0oobs8fux5ohohkjcuqxnjk-nyjawidth-1616format-png.png 500w" sizes="250px" width="250" height="250" alt="Generate TwiML using Strings in C#" decoding="async" loading="lazy" style="background-color:#121c2d"></picture>

## How to generate TwiML using Strings in C#

2/21/2023 - .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.



](/blog/dotnet/how-to-generate-twiml-using-strings-in-csharp)[

<picture><img class="blog-post-card__image" src="/cdn-cgi/image/width=250,format=auto,quality=90,height=250,fit=cover/media/aiddtixz/py9oh53qzeh8edhp301dzk4s05noejgmod-_cncljfkrrwidth-1616.png" srcset="/cdn-cgi/image/width=250,format=auto,quality=90,height=250,fit=cover/media/aiddtixz/py9oh53qzeh8edhp301dzk4s05noejgmod-_cncljfkrrwidth-1616.png 250w, /cdn-cgi/image/width=375,format=auto,quality=90,height=375,fit=cover/media/aiddtixz/py9oh53qzeh8edhp301dzk4s05noejgmod-_cncljfkrrwidth-1616.png 375w, /cdn-cgi/image/width=500,format=auto,quality=90,height=500,fit=cover/media/aiddtixz/py9oh53qzeh8edhp301dzk4s05noejgmod-_cncljfkrrwidth-1616.png 500w" sizes="250px" width="250" height="250" alt="Use Raw String Literals to generate TwiML in C# 11" decoding="async" loading="lazy" style="background-color:#fff"></picture>

## Use Raw String Literals to generate TwiML in C# 11

2/15/2023 - .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.



](/blog/dotnet/use-raw-string-literals-to-generate-twiml-in-csharp-11)[

<picture><img class="blog-post-card__image" src="/cdn-cgi/image/width=250,format=auto,quality=90,height=250,fit=cover/media/lyung0ju/use_visual_studio_port_tunneling.png" srcset="/cdn-cgi/image/width=250,format=auto,quality=90,height=250,fit=cover/media/lyung0ju/use_visual_studio_port_tunneling.png 250w, /cdn-cgi/image/width=375,format=auto,quality=90,height=375,fit=cover/media/lyung0ju/use_visual_studio_port_tunneling.png 375w, /cdn-cgi/image/width=500,format=auto,quality=90,height=500,fit=cover/media/lyung0ju/use_visual_studio_port_tunneling.png 500w" sizes="250px" width="250" height="250" alt="Use Visual Studio dev tunnels to handle Twilio Webhooks" decoding="async" loading="lazy" style="background-color:#fff"></picture>

## Use Visual Studio dev tunnels to handle Twilio Webhooks

2/8/2023 - .NET

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



](/blog/dotnet/use-visual-studio-dev-tunnels-to-handle-twilio-webhooks)[

<picture><img class="blog-post-card__image" src="/media/j0idt3az/vb-net_logo.svg" width="250" height="250" alt="Visual Basic logo" decoding="async" loading="lazy" style="background-color:#fff"></picture>

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

8/25/2022 - .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.



](/blog/dotnet/create-an-aspdotnet-core-minimal-api-with-vbdotnet)[

<picture><img class="blog-post-card__image" src="/cdn-cgi/image/width=250,format=auto,quality=90,height=250,fit=cover,gravity=0.5x0.25765433625642226/media/fbubucw4/ios-screenshot_iphone13red_portrait.png" srcset="/cdn-cgi/image/width=250,format=auto,quality=90,height=250,fit=cover,gravity=0.5x0.25765433625642226/media/fbubucw4/ios-screenshot_iphone13red_portrait.png 250w, /cdn-cgi/image/width=375,format=auto,quality=90,height=375,fit=cover,gravity=0.5x0.25765433625642226/media/fbubucw4/ios-screenshot_iphone13red_portrait.png 375w, /cdn-cgi/image/width=500,format=auto,quality=90,height=500,fit=cover,gravity=0.5x0.25765433625642226/media/fbubucw4/ios-screenshot_iphone13red_portrait.png 500w" sizes="250px" width="250" height="250" alt="Conversation between an iPhone user and the SMS bot. The user says &quot;Hi&quot; and the bot responds with &quot;Welcome to the U.S. Representative lookup bot. Respond with your address. The user sends an address and the bot responds with &quot;Your representative is Gerald E. Connolly (Democratic Party) representing Virginia&quot;s 11th congressional district. Then the bot sends an image of the representative." decoding="async" loading="lazy" style="background-color:#0f1038"></picture>

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

8/2/2022 - .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.



](/blog/dotnet/find-your-us-representatives-and-congressional-districts-with-sms-and-aspdotnet-core)[

<picture><img class="blog-post-card__image" src="/cdn-cgi/image/width=250,format=auto,quality=90,height=250,fit=cover,gravity=1x0/media/0rymdlyj/how-to-bulk-email-with-c-and-net.png" srcset="/cdn-cgi/image/width=250,format=auto,quality=90,height=250,fit=cover,gravity=1x0/media/0rymdlyj/how-to-bulk-email-with-c-and-net.png 250w, /cdn-cgi/image/width=375,format=auto,quality=90,height=375,fit=cover,gravity=1x0/media/0rymdlyj/how-to-bulk-email-with-c-and-net.png 375w, /cdn-cgi/image/width=500,format=auto,quality=90,height=500,fit=cover,gravity=1x0/media/0rymdlyj/how-to-bulk-email-with-c-and-net.png 500w" sizes="250px" width="250" height="250" alt=".NET bot flying with a jetpack" decoding="async" loading="lazy" style="background-color:#0d122b"></picture>

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

8/2/2022 - .NET

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



](/blog/dotnet/how-to-bulk-email-with-csharp-and-dotnet-zero-to-hero)[

<picture><img class="blog-post-card__image" src="/cdn-cgi/image/width=250,format=auto,quality=90,height=250,fit=cover/media/kcceyrkd/dotnet-bot.png" srcset="/cdn-cgi/image/width=250,format=auto,quality=90,height=250,fit=cover/media/kcceyrkd/dotnet-bot.png 250w, /cdn-cgi/image/width=375,format=auto,quality=90,height=375,fit=cover/media/kcceyrkd/dotnet-bot.png 375w, /cdn-cgi/image/width=500,format=auto,quality=90,height=500,fit=cover/media/kcceyrkd/dotnet-bot.png 500w" sizes="250px" width="250" height="250" alt="Provide default configuration to your .NET applications" decoding="async" loading="lazy"></picture>

## Provide default configuration to your .NET applications

5/23/2022 - .NET

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



](/blog/dotnet/provide-default-configuration-to-your-dotnet-applications)[

<picture><img class="blog-post-card__image" src="/media/hygn4t2f/twilio-icon.svg" width="250" height="250" alt="Twilio logo" decoding="async" loading="lazy"></picture>

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

5/12/2022 - .NET

Learn how to configure your .NET applications better for sending SendGrid emails



](/blog/dotnet/how-to-better-configure-csharp-and-dotnet-applications-for-sendgrid)[

<picture><img class="blog-post-card__image" src="/cdn-cgi/image/width=250,format=auto,quality=90,height=250,fit=cover,gravity=0.5x0.5/media/daadzjni/dotnet-bot_builder.png" srcset="/cdn-cgi/image/width=250,format=auto,quality=90,height=250,fit=cover,gravity=0.5x0.5/media/daadzjni/dotnet-bot_builder.png 250w, /cdn-cgi/image/width=375,format=auto,quality=90,height=375,fit=cover,gravity=0.5x0.5/media/daadzjni/dotnet-bot_builder.png 375w, /cdn-cgi/image/width=500,format=auto,quality=90,height=500,fit=cover,gravity=0.5x0.5/media/daadzjni/dotnet-bot_builder.png 500w" sizes="250px" width="250" height="250" alt=".NET Bot holding a browser URL bar and a toolbox" decoding="async" loading="lazy"></picture>

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

4/24/2022 - .NET

Learn how to get the public full URL of your ASP.NET Core application



](/blog/dotnet/how-to-get-the-full-public-url-of-aspdotnet-core)[

<picture><img class="blog-post-card__image" src="/cdn-cgi/image/width=250,format=auto,quality=90,height=250,fit=cover,gravity=0.5x0.5/media/3chhuuzk/dotnet-bot_builder.png" srcset="/cdn-cgi/image/width=250,format=auto,quality=90,height=250,fit=cover,gravity=0.5x0.5/media/3chhuuzk/dotnet-bot_builder.png 250w, /cdn-cgi/image/width=375,format=auto,quality=90,height=375,fit=cover,gravity=0.5x0.5/media/3chhuuzk/dotnet-bot_builder.png 375w, /cdn-cgi/image/width=500,format=auto,quality=90,height=500,fit=cover,gravity=0.5x0.5/media/3chhuuzk/dotnet-bot_builder.png 500w" sizes="250px" width="250" height="250" alt=".NET Bot holding a browser URL bar and a toolbox" decoding="async" loading="lazy"></picture>

## How to generate absolute URLs in ASP.NET Core

4/19/2022 - .NET

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



](/blog/dotnet/how-to-generate-absolute-urls-in-aspdotnet-core)[

<picture><img class="blog-post-card__image" src="/media/sc2jqzpo/twilio-icon.svg" width="250" height="250" alt="Twilio logo" decoding="async" loading="lazy"></picture>

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

4/11/2022 - .NET

Learn how to use multiple configuration sources, strongly-typed objects, and implement the options pattern in your .NET applications



](/blog/dotnet/how-to-better-configure-csharp-and-dotnet-applications-for-twilio)[

<picture><img class="blog-post-card__image" src="/cdn-cgi/image/width=250,format=auto,quality=90,height=250,fit=cover,gravity=0.9774396673856787x0.9247216931560068/media/nlup5klu/what-s-new-in-the-twilio-helper-library-for-asp-net-v5-73-0-march-2022.png" srcset="/cdn-cgi/image/width=250,format=auto,quality=90,height=250,fit=cover,gravity=0.9774396673856787x0.9247216931560068/media/nlup5klu/what-s-new-in-the-twilio-helper-library-for-asp-net-v5-73-0-march-2022.png 250w, /cdn-cgi/image/width=375,format=auto,quality=90,height=375,fit=cover,gravity=0.9774396673856787x0.9247216931560068/media/nlup5klu/what-s-new-in-the-twilio-helper-library-for-asp-net-v5-73-0-march-2022.png 375w, /cdn-cgi/image/width=500,format=auto,quality=90,height=500,fit=cover,gravity=0.9774396673856787x0.9247216931560068/media/nlup5klu/what-s-new-in-the-twilio-helper-library-for-asp-net-v5-73-0-march-2022.png 500w" sizes="250px" width="250" height="250" alt=".NET Bot holding a phone and bag with the Twilio logo" decoding="async" loading="lazy"></picture>

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

4/6/2022 - .NET

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



](/blog/dotnet/whats-new-in-the-twilio-helper-library-for-aspdotnet-april-2022)[

<picture><img class="blog-post-card__image" src="/media/rffnhcsk/twilio-icon.svg" width="250" height="250" alt="Twilio logo" decoding="async" loading="lazy"></picture>

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

4/5/2022 - .NET

You don't always need a phone number to send SMS! Learn how to send text messages using Alphanumeric Sender IDs.



](/blog/dotnet/send-sms-without-phone-number-using-csharp-dotnet-and-alphanumeric-sender-id)[

<picture><img class="blog-post-card__image" src="/cdn-cgi/image/width=250,format=auto,quality=90,height=250,fit=cover,gravity=1x1/media/jn2ohzgd/how-to-prevent-email-html-injection-in-c-and-net.png" srcset="/cdn-cgi/image/width=250,format=auto,quality=90,height=250,fit=cover,gravity=1x1/media/jn2ohzgd/how-to-prevent-email-html-injection-in-c-and-net.png 250w, /cdn-cgi/image/width=375,format=auto,quality=90,height=375,fit=cover,gravity=1x1/media/jn2ohzgd/how-to-prevent-email-html-injection-in-c-and-net.png 375w, /cdn-cgi/image/width=500,format=auto,quality=90,height=500,fit=cover,gravity=1x1/media/jn2ohzgd/how-to-prevent-email-html-injection-in-c-and-net.png 500w" sizes="250px" width="250" height="250" alt="How to prevent Email HTML injection in C# and .NET" decoding="async" loading="lazy" style="background-color:#06033a"></picture>

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

4/1/2022 - .NET

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



](/blog/dotnet/how-to-prevent-email-html-injection-in-csharp-and-dotnet)[

<picture><img class="blog-post-card__image" src="/cdn-cgi/image/width=250,format=auto,quality=90,height=250,fit=cover,gravity=0.5x0.5/media/xw3pvku3/sendgrid-logomark.png" srcset="/cdn-cgi/image/width=250,format=auto,quality=90,height=250,fit=cover,gravity=0.5x0.5/media/xw3pvku3/sendgrid-logomark.png 250w, /cdn-cgi/image/width=375,format=auto,quality=90,height=375,fit=cover,gravity=0.5x0.5/media/xw3pvku3/sendgrid-logomark.png 375w, /cdn-cgi/image/width=500,format=auto,quality=90,height=500,fit=cover,gravity=0.5x0.5/media/xw3pvku3/sendgrid-logomark.png 500w" sizes="250px" width="250" height="250" alt="Twilio SendGrid logo" decoding="async" loading="lazy"></picture>

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

3/15/2022 - .NET

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



](/blog/dotnet/send-aspdotnet-core-identity-emails-with-twilio-sendgrid)[

<picture><img class="blog-post-card__image" src="/cdn-cgi/image/width=250,format=auto,quality=90,height=250,fit=cover,gravity=0.5x0.5/media/0y4b3pnt/sendgrid-logomark.png" srcset="/cdn-cgi/image/width=250,format=auto,quality=90,height=250,fit=cover,gravity=0.5x0.5/media/0y4b3pnt/sendgrid-logomark.png 250w, /cdn-cgi/image/width=375,format=auto,quality=90,height=375,fit=cover,gravity=0.5x0.5/media/0y4b3pnt/sendgrid-logomark.png 375w, /cdn-cgi/image/width=500,format=auto,quality=90,height=500,fit=cover,gravity=0.5x0.5/media/0y4b3pnt/sendgrid-logomark.png 500w" sizes="250px" width="250" height="250" alt="Twilio SendGrid logo" decoding="async" loading="lazy" style="background-color:#fff"></picture>

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

3/8/2022 - .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



](/blog/dotnet/how-to-send-email-in-csharp-dotnet-using-smtp-and-sendgrid)[

<picture><img class="blog-post-card__image" src="/media/vgye2zpp/twilio-mark-red-e1886ea5f.svg" width="250" height="250" alt="Twilio logo" decoding="async" loading="lazy" style="background-color:#fff"></picture>

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

2/4/2022 - .NET

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



](/blog/dotnet/send-scheduled-sms-with-csharp-dotnet-and-twilio-programmable-messaging)[

<picture><img class="blog-post-card__image" src="/media/dikleklg/dotnet-bot_builder.svg" width="250" height="250" alt=".NET Bot" decoding="async" loading="lazy" style="background-color:#fff"></picture>

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

1/25/2022 - .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.



](/blog/dotnet/how-to-get-aspdotnet-core-server-urls)

[Show All Posts](/blog/csharp/all#main-content)[Next Page](/blog/csharp/page/2#main-content)

[Next](/blog/csharp/page/2#main-content)
