我有一个托管在单独服务器上的 ASP.NET 应用程序。我连接Application_BeginRequest()
到 Global.asax.cs
protected void Application_BeginRequest(Object sender, EventArgs e)
{
//logging here
}
现在我创建了一个带有自签名证书的 .pfx 文件,并尝试使用该证书在服务器上请求 URL。
以下代码运行良好:
String url = "https://myserver.com/MyController/Magic";
var request = (HttpWebRequest)WebRequest.Create(url);
var response = request.GetResponse();
我Application_BeginRequest()
在日志中看到了日志记录。
但是下面的代码(到相同的 URL)
String url = "https://myserver.com/MyController/Magic";
var request = (HttpWebRequest)WebRequest.Create(url);
var certData = File.ReadAllBytes(pathToPfxFile);
var cert = new X509Certificate2(certData, password);
request.ClientCertificates.Add(cert);
var response = request.GetResponse();
它只加载证书并将其附加到请求中总是产生 HTTP 403.16,我没有Application_BeginRequest()
在日志中看到日志记录。
我错过了什么?为什么请求不会传递给托管代码?