2 ms·
C#/.NET is my go to always. But, I have a really hard time loving Blazor, and most of the other non-essentials that are piled on top of HttpContext. My current
by bob1029 2y ago
C#/.NET is my go to always. But, I have a really hard time loving Blazor, and most of the other non-essentials that are piled on top of HttpContext.
My current preference is to lean on string interpolation [0] to do most of the heavy lifting when rendering web documents on the server. You can nest interpolations and use LINQ + collection aggregation (string.Join()) to trivially build things like tables and other complex documents. Combine interpolation with verbatim [1], and you basically get a poor man's PHP document system nested within your C# source files. I've done the whole razor template thing and I am completely over that. Managing the dependencies and weird initialization routines for these rendering engines is not worth it when the language has a built-in feature that accomplishes virtually the same thing with absolutely zero BS.
Writing raw HTML to the client is a simple one-liner [2]. You can quickly build your own bespoke web frameworks, leveraging the power of features like reflection to make your life 100x easier. You can sidestep virtually all of the AspNetCore namespaces and the attribute-driven nonsense that is hallmark of most .NET/MVC-style web apps. If you keep it light and avoid the boilerplate, you can do a lot of damage within 100 lines of code these days.
[0] https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/tokens/interpolated https://learn.microsoft.com/en-us/dotnet/csharp/language-ref...
[1] https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/tokens/verbatim https://learn.microsoft.com/en-us/dotnet/csharp/language-ref...
[2] https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.http.httpresponsewritingextensions.writeasync https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspne...