Frameworks can be secured as far as their internal implementations go, but they can't stop you from exposing yourself to these vulnerabilities yourself. There's no shortcut to this -- you need to study common attack vectors in web protocols and web browsers.
In general, you're better off with popular, open-source frameworks that are still getting updates by a team of paid professionals (usually through corporate sponsorship). Strong, static types also help.
For a beginner, .NET 6 is a pretty good "batteries included" starting point that doesn't require as much caution when importing third-party libraries (as opposed to Node/npm).