ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };加在哪
时间: 2024-02-01 13:12:09 浏览: 20
`ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };` 这行代码可以用于跳过 SSL 证书验证。如果你想要在整个应用程序中都跳过 SSL 证书验证,可以考虑将其放在应用程序的入口点(如 `Main` 方法)中,或者放在应用程序启动时所执行的一段初始化代码中。这样可以确保在整个应用程序中都跳过 SSL 证书验证。
如果你只想在某个特定的方法或代码块中跳过 SSL 证书验证,可以将该行代码放在该方法或代码块的开头。注意,在这种情况下,你需要在代码块结束时将 `ServicePointManager.ServerCertificateValidationCallback` 设置为 `null`,以恢复 SSL 证书验证。