The key here is Principal. 40 plus is considered fine and good for Architects/Managers and people in leadership positions. Try to get a senior engineer or below job where you are expected to be grinding out code instead.
Granted, not everyone enjoys doing it, and it comes with lots of politics as baggage as well.
But yes, I have that experience in my background. I had my first principal role back when I was 32 (but prior to switching away from .NET development) and 2 other lead roles in my 30s.
We have a bunch of .NET devs (our BE is .NET) and the average age of these folks probably right around 40, because in general they're going to be older devs who do that.