【问题标题】:Intercept Http call to SSL certificate拦截对 SSL 证书的 Http 调用
【发布时间】:2009-05-06 16:02:27
【问题描述】:

有没有办法拦截 WebBrowser 对 SSL 的调用(在 asp.net 应用程序中)?在发出请求之前,我需要在运行时将参数传递给 http-headers。

示例:如果我输入“http://test.com”,浏览器将与服务器通信并返回“https://test1.com”作为安全 URL。我应该能够拦截呼叫并将标头信息(确定原始主机的键、值)传递给http://test.com。还是有更好的解决方案来实现这一点?

提前致谢

【问题讨论】:

  • 不确定您的意思... 是在 ASP.NET 应用程序中进行的拦截。还是要在中间放一个代理?
  • 在 asp.net 应用程序本身中。

标签: c# asp.net http http-headers ssl-certificate


【解决方案1】:

我做了以下强制用户使用 HTTPS:

protected override void OnPreInit(EventArgs e)
{
    if (string.Compare(Request.ServerVariables["HTTPS"], "OFF", true) == 0)
    {
        StringBuilder builder = new StringBuilder("https://");
        builder.Append(Request.ServerVariables["SERVER_NAME"]);
        builder.Append(Request.ServerVariables["URL"]);
        Response.Redirect(builder.ToString());
        return;
    }

    base.OnPreInit(e);
}

你应该能够修改它来做你需要的。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-11-08
    • 2018-07-08
    • 2014-01-07
    • 2022-01-17
    • 2017-01-15
    • 2020-04-28
    • 2023-03-13
    • 2021-11-18
    相关资源
    最近更新 更多