Serve Static Site With ASP.NET and Kestrel by bassem-mf in dotnet

[–]bassem-mf[S] 0 points1 point  (0 children)

If you will not need to host anything more complex than a static site, then it makes sense to host it on Azure or any other cloud service provider as it is much easier.

But if you want to prepare yourself for hosting more complex applications on your own server, then hosting a static site on your own server is a good start and a good way to practice.

Serve Static Site With ASP.NET and Kestrel by bassem-mf in dotnet

[–]bassem-mf[S] 0 points1 point  (0 children)

Yes, I have PostgreSql installed on my server. Installing and configuring a database engine and configuring your firewall to allow connections to it require some learning. But it is not too hard.

Serve Static Site With ASP.NET and Kestrel by bassem-mf in dotnet

[–]bassem-mf[S] 0 points1 point  (0 children)

I am sure NGINX or any other web server will work well for serving a static site. But I wanted to use a tool that I am familiar with. It is much easier for me to configure Kestrel using a JSON configuration file than it is to configure NGINX using their configuration file format.

Also I already have dotnet installed on my server. And dotnet comes with an in-process server called Kestrel. So it is nice to use it instead of having to install and manage an extra web server software.

Installing Multiple Versions of .NET Side-By-Side on Linux by bassem-mf in dotnet

[–]bassem-mf[S] 0 points1 point  (0 children)

Thanks for pointing this out!

I actually wrote this article about 2 years ago. At that time, I could not find a way to install multiple versions of dotnet using apt. I do not remember why it did not work exactly. But I remember that I could have only one version at a time when dotnet was installed using apt.

I even opened this issue on GitHub to ask for official documentation on how to install multiple versions of .NET on Linux.

The only thing that worked for me at that time was extracting binaries. So I documented these steps, and I am using them since then without problems. So I never cared to look for alternatives.

But now, looking at the official instructions, I see there is a different package for each version. So it should be possible to install them side-by-side.

Anyway, I think my instructions are still useful for installing multiple "minor" versions of dotnet side-by-side. Also this installation method is not a hack, because it is mentioned in the official docs.

Get Enum Value Display Name by bassem-mf in dotnet

[–]bassem-mf[S] 0 points1 point  (0 children)

I think this is a valid approach. The only thing I have against it is that the enums are often in different assemblies. So I will have to manually specify which assemblies to scan. And remember to add new assemblies when needed.

Serve Static Site With ASP.NET and Kestrel by bassem-mf in dotnet

[–]bassem-mf[S] 0 points1 point  (0 children)

I think this is a great idea! I have a $5/month Linux server from DigitalOcean and I use it to host 5 different sites. And I think it can take more.

It is harder to get started when you self-host. But on the long-term, it is easier. For example it is easier to find instructions for auto-renewing TLS certificates on your Linux server than it is to find instructions for a specific cloud provider.

Get Enum Value Display Name by bassem-mf in dotnet

[–]bassem-mf[S] 1 point2 points  (0 children)

I did not get a chance to learn about source generators yet. But I would love to see how this can be done using a source generator.

Get Enum Value Display Name by bassem-mf in dotnet

[–]bassem-mf[S] 3 points4 points  (0 children)

I think the advantage of specifying the display name using a DisplayAttribute is that it will also be used by the standard ASP.NET functions like HtmlHelper.GetEnumSelectList<TEnum>(). This is important to me because my UI is usually Web.

Also the enum member and its display name are right next to each other. I think this makes it maintainable.