我正在尝试从 Blazor WebASM 项目向 Web api 发出请求。托管 web api 的服务器是具有自签名证书的开发人员计算机。我已经配置了 CORS。我正在尝试使用以下代码绕过证书:
using( var httpClientHandler = new HttpClientHandler() )
{
httpClientHandler.ServerCertificateCustomValidationCallback = ( message, cert, chain, errors ) => { return true; };
using( var client = new HttpClient( httpClientHandler ) )
{
// Make your request...
}
}
Run Code Online (Sandbox Code Playgroud)
无论如何,我收到以下错误:
blazor.webassembly.js:1 System.PlatformNotSupportedException:不支持属性 ServerCertificateCustomValidationCallback。