In .NET core, you should do this at the HttpClient level rather than use the ServicePointManager object, e.g.
https://stackoverflow.com/a/44540071/1538039
I answered a similar question to this here - https://stackoverflow.com/a/55358543/1538039
While you can bypass the validation in this way, it's not the correct approach if you control the server. You're basically saying 'I've configured the server in a way that means my client can't establish trust, because it doesn't implicitly trust the certificate chain. To get around this, I'm going to accept all errors by adding some code'
A better solution is to configure the server with a certificate the client can trust, and then things will just work!
At development time working locally, if you want to use a self-signed certificate then you can install it as a root CA and things should work as expected.
Once you've got to a stage where you don't control the client, this obviously isn't something you can ask people to do. The only thing to do then is to correctly configure the server with a certificate the client can trust, using something like letsencrypt to generate the cert.