r/DotNet
9 subscribers
612 photos
88 videos
13K links
.NET Community, if you are using C#, VB.NET, F#, or anything running with .NET... you are at the right place!

https://www.reddit.com/r/dotnet

Part of @reddit2telegram and @r_channels

@JavaOfftopic
Download Telegram
ASP.NET Core learning tool

developing a platform for learning, in a more practical way for some time now. The idea is to combine guided lessons, code examples, and challenges. At the end of each challenge, you can submit your solution and receive feedback from an AI that evaluates it according to certain criteria, highlighting what you did well and the areas for improvement.

https://redd.it/1v1wx56
@r_dotnet
TabControl UI problems

Hi, Im working on an application in vb.net and there were too many forms on the screen at once so I found out about tabcontrols. I decided to test it out a little but Ive run into a problem with how it looks.

When I hook or anchor buttons or other things to the edges of the form they dont show correctly in the tabcontrol. My goal is for the application to be maximized for most, if not all, of the forms. When the tabcontrol is started maximized, the controls at the bottom dont show correctly. It seems like the form is using the fullscreen size while the tabcontrol is using the maximized size.

Im not sure how to fix this other than manually formatting every single form to account for the computer's application ribbon, which I dont want to do for obvious reasons. I went to the form being displayed and made sure it wasnt locked to a specific size and it isnt set to fullscreen either. Surely there is an easy way?

Also, I learned vb.net about 10 years ago in a class at college. I may not be up to date on the most current tools. How does one make applications look modern? I havent found any default control designs that look sleek and fit together flush, but maybe Im looking in the wrong place. Where can I find things like that or how do I format them nicely?

Thanks in advance

https://redd.it/1v2ojhc
@r_dotnet
CorrelationIds vs TraceId

I am currently in the process of integrating Open Telemetry into my code. I have a web application and a backend api. I have several REST APIs and one of the APIs also ends up getting invoked by the user -> kicks off an async process by triggering a background job -> the background job invokes and polls on a specific endpoint (downstream API). The web app also polls on an operations endpoint to get status of this background job basically. Additionally, I also invoke some Azure resources (specifically ARM).


Now that I provided context, I wanted to explain what currently exists in my backend:

1) Controller fetches the correlationId for every request using the headers (x-correlation-id) from a middleware

2) Automatically forwards this correlationId when invoking downstream APIs/Azure APIs

3) Passes it into each method starting from the controller: controller invokes singletonServiceA.methodA and methodA has a signature including the correlationId. From here the logs automatically capture the correlationId

4) Background jobs also use this correlationId to invoke APIs and for logging


Now that I am switching to OTel, I am seeing an entirely different convention which I'm unsure on how to relate together.


My questions are as follows:
1) Should I drop the manual propagation of correlationId everywhere and just keep it as a span attribute? From what I am finding out, I definitely need to do this

2) For legacy resources, let's say ARM which expect a correlationID, what should I do?

3) For downstream APIs, should I switch to sending them a traceparent instead of the correlationId (what I do right now)

https://redd.it/1v2qimk
@r_dotnet
Services and ViewModel in Blazor desktop app - when to use what.

I'm porting WinForms app to Blazor with Blazing.MVVM.

In which cases should I pass data between model and view using VewModel and when to prefer to simply inject a service directly into razor?

I'm asking because I understand that technically everything can be done via VM but sometimes it looks like it creates needless code volume overhead. On the other hand it also seems like using services can gradually lead me to tightly coupling UI and logic in the old Winforms way.

If possible, provide examples (not code, descriptive).

Thanks.

https://redd.it/1v3987b
@r_dotnet
Deploying Agent on Buildserver

In my company I'm in charge of building multiple AI agents:

\- code review (only comments for now, eventually directly fixing small things like typos in naming)

\- code gen (we have vertical slice architecture so simple repetitive things like enabling business directly setting master data from frontend requires like 45+ files / about 3-4h of dev work)

\- pentesting agent

Our infra:

Dotnet backend deployed to multiple IIS depending on project.

Separate Build Server for automatically pulling master branch, building and deploying

Now the CTO wants to deploy the Agents to the Build Server. Imo this is a Terrible idea, since prompt injection is deffo possible.

Would love to hear what your thoughts are.

https://redd.it/1v3ck0h
@r_dotnet
Transitioning from Java / Spring Boot to .NET

I've been moved to another department that uses .NET and Azure as the tech stack.

While having no problem picking up the language and the basics of ASP.NET, I'm having trouble finding resources online that go really deep on the framework.

Microsoft Resources are bad in my opinion, too messy.

The job itself is simple, but I was thinking about going 100% in this framework.

Any suggestions? Even paid.

https://redd.it/1v3lqh9
@r_dotnet
FCQRS 6 released: event-sourced CQRS with two pure functions
https://redd.it/1v3o3uz
@r_dotnet
How do I prepare for dotnet interviews??

Hi guys,
I joined a service-based company around 4–5 years ago, but I never really got the opportunity to work on a proper development project. Most of my work has been on the support side... bug fixes, minor enhancements, and database updates.
I'm now looking to switch, but I'm not sure how to prepare effectively. I've attended a few interviews, and most of them were heavily focused on scenario based questions, which I found quite challenging.
How should I prepare from here? What topics should I focus on, and how can I bridge the gap between my current experience and what companies expect from a developer?
Any guidance, resources, or advice would be greatly appreciated.
Thank You!!! 🙏🏽

https://redd.it/1v3jdmj
@r_dotnet
So, what about MAUI on Linux?

Certainly I cannot be the only one who remembers when they announced running MAUI on Linux through Avalonia and I am not afraid to say I need that YESTERDAY for a project of mine.

But as much as I tried searching online I've yet to see anything I can use for the purpose. What's the deal? Does anyone have any info?

https://redd.it/1v3srbl
@r_dotnet
What do you think about XAML?

Yesterday, I’ve started working with MAUI, because I want to try out some multiplatform mobile development and I love C# (so MAUI was an obvious choice).

So after a few hours working with xaml I don’t really know how to feel about it. It’s definitely more convinient than WindowsForms or swing, but it somehow feels very clunky.

My question for you is: how do you manage your xaml projects, in terms of complexity and readability?

I don’t really have any experience in mvvm development so I am interested in your thoughts.

https://redd.it/1v494y2
@r_dotnet
ASP.NET Core on IIS randomly goes offline for 2 minutes. no errors, no recycle, but TCP CLOSE_WAIT spikes

Hi everyone,

A few weeks ago I posted here about a strange production issue we were having:

[https://www.reddit.com/r/dotnet/s/sdmADloeNS](https://www.reddit.com/r/dotnet/s/sdmADloeNS)

First, I want to say thank you to everyone who replied there. The comments gave me a lot of ideas and helped me improve my monitoring and investigation approach.

I wanted to give an update because I found some new interesting clues, but I still haven't found the root cause.

# The problem

Our website randomly becomes unavailable for around 1-2 minutes, then comes back by itself.

The monitoring tools report: `Socket timeout, unable to connect to server`

Not an HTTP error like 500 or 503.

The strange thing is that during these incidents:

\- DNS is fine

\- The Windows server itself is still online

\- CPU looks normal

\- RAM looks normal

\- Disk looks normal

\- IIS logs don't show failed requests

\- [ASP.NET](https://ASP.NET) Core logs don't show anything useful

This made me suspect that the request is not even reaching [ASP.NET](https://ASP.NET) Core.

# New things I tried

I installed Uptime Kuma directly on the same server and configured it to monitor the website using the server IP address instead of the domain name.

The interesting part is that it still detects the outage.

So this makes me think it is not related to:

\- So this makes me think it is not related to:

\- DNS

\- Domain resolution

\- External monitoring location

\- Some issue before reaching the server

I also checked IIS and confirmed that there was no App Pool recycle and no w3wp.exe restart during the outage.

Another interesting observation:

I have multiple applications running on different IIS App Pools on the same server. During the outage, the other applications continued working normally.

# The TCP connection clue

I started collecting TCP state metrics and sending them to Grafana.

During the outage, I noticed a big change in TCP connections.

The most suspicious thing was `CLOSE_WAIT`.

Before the issue:

Established: ~450
CloseWait: 0

During the issue:

Established: ~200-400
CloseWait: 500+

Example:

12:02
Established: 451
CloseWait: 327

12:03
Established: 237
CloseWait: 510

12:04
Established: 224
CloseWait: 530

Then suddenly:

12:04
Established: 845
CloseWait: 73

12:04
Established: 859
CloseWait: 0

I attached a screenshot from Grafana showing the TCP connection spike.

[Grafana TCP connections during the outage.](https://preview.redd.it/5cnpnnz7v6fh1.png?width=1801&format=png&auto=webp&s=fb6a16441eca2f91303b3e43c1101f2a6257eec3)

This made me start thinking that the problem might be happening somewhere around the TCP layer rather than inside [ASP.NET](https://ASP.NET) Core itself.

# Code changes

During the investigation, I also found some places where we were creating new `HttpClient` instances instead of reusing them.

I already fixed those and moved them to reusable `HttpClient` usage.

However, the problem still happens, so this was probably not the only cause.

# What I am thinking now

At the moment I am investigating more around:

\- Windows TCP/socket behavior

\- IIS/HTTP.sys

\- Connection handling

\- Possible socket leaks

\- Anything that can make the server stop accepting new connections temporarily

The biggest question for me is:

How can the server become unreachable from TCP level while:

\- IIS is still running

\- App Pools are healthy

\- CPU/RAM/Disk are normal

\- No application errors are logged?

# Questions

For people who have dealt with similar IIS/Windows production issues:

\- Have you seen cases where clients get socket timeouts but IIS has no logs at all?

\- Does a large CLOSE\_WAIT increase usually point to an application problem?

\- Can HTTP.sys or IIS have issues without restarting the App Pool?

\- What Windows-level
metrics would you check for this type of problem?

\- Any recommended tools for debugging TCP connection issues on Windows?

I am still investigating and will update again if I find the cause.

Thanks again to everyone who helped in the previous post!

https://redd.it/1v5d7ws
@r_dotnet
First preview of ProGPU Avalonia rendering platform and Silk.NET windowing platform for Avalonia bringing powerful ProGPU WebGPU based rendering
/r/ProGPU/comments/1v5kxst/first_preview_of_progpu_avalonia_rendering/

https://redd.it/1v5kyer
@r_dotnet
An update on the world of PeachPDF

PeachPDF is the HTML -> PDF engine I've been building for the last decade that renders HTML into PDF without using a headless browser or external process.

We target .NET 8+, but we also multi-target .NET 10+. We support everywhere .NET 8+ runs, though some features don't work on certain platforms. As an example, iOS doesn't expose system fonts directly as font files, so you have to register fonts directly.

Some updates:

We launched a website: https://peachpdf.net/ This has all of the documentation you'd ever need

I also added a lot of new features:

1. SVG support -- we already have a very good graphics abstraction, so SVG support is essentially just building a scene graph and rendering it, with some basic integration with the other parts of the stack (CSS Cascade, layout inside HTML)

2. CSS Grid support

3. Lots of CSS parsing updates, such as nested CSS, @layer support, CSS Properties, @media evaluation and correctness fixes

3. New CSS layout and painting features: clip-path, aspect-ratio, object-fit

4. CSS Color updates

5. Improved font support: we now use runes for lookup, and we use CSS unicode-range for matching, and we added support for monochrome and color emojis. For features not natively supported by PDF, we can extract the glyph outlines from the font and paint the text as vectors. This was needed for color emojis and several SVG text features

6. More paged media improvements

7. A new .NET AOT command line tool that wraps PeachPDF for use where the .NET library doesn't make sense. Future plans include exposing PeachPDF as a C library so that it can be used from Node.js and Python as well.

As a side project, I've also been working on back porting improvements to the upstream projects that I depend on, such as ExCSS and HTML-Renderer. ExCSS just released a new version that is almost all backports from PeachPDF, and the first 2 foundational features have outstanding PRs waiting approval to HTML-Renderer

And to answer a question -- there is significant use of AI for spec conformance features. It's a great use of AI, since it can read a specification and identity gaps. All of the non-mechanical work is done by myself. Considering I started writing this 10 years ago, it's not a vibe coded project since that didn't even exist when I started.

https://redd.it/1v6b0i0
@r_dotnet