No Current Flowing From 12v Solenoid Pins
You are trying to drive a non-logic level IRF540N MOSFET from the (max) 3.3 V logic output of the ESP32.
That ESP32 3.3 V GPIO output might just reach the Vgs(th) of the MOSFET, which is specified at 250 uA of drain current - but that's not enough current to drive your solenoid!

When hooking up the boards power supply directly to the solenoid everything fires as expected

That works because you are then supplying 12 V (i.e. the board's power supply voltage) to the MOSFET's gate, instead of the 3.3 V from the ESP32 GPIO pin.
You need to use a logic-level MOSFET instead, with a suitable specified Rds(on) at your ESP32's logic-level voltage of 3.3 V.
For example, the IRL540N (notice IRL540N, not IRF540N) could pass around 20 A at Vgs = 3.3 V according to its datasheet, but there are many suitable MOSFETs. Check with your suppliers. Just remember that those specified with Vgs = 10 V (like your IRF540N) are unlikely to be suitable, when you are driving the gate with only 3.3 V.

Not directly related to your question, but if I am interpreting your schematic correctly (a larger version of the image would make it easier to read, if you have one) then C1 is the only capacitor on the 12 V rail and it's only 100 nF. Since that 12 V rail powers both the solenoid and the logic (through a 3.3 V regulator) then additional bulk capacitance may be needed.