views:

262

answers:

1

Is there a way to intercept a call made by WebBrowser to SSL (within in an asp.net application)? I need to pass parameters to http-headers at runtime before the request is made.

Example: if I type "http://test.com", the browser communicates with the server and returns "https://test1.com" as the secured url. I should be be able to intercept the call and pass in headder information (key, value that determines the original host) to http://test.com. Or is there a better solution to achieve this?

Thanks in advance

A: 

I do the following to force users to use 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);
}

You should be able to modify it to do what you need.

Jonathan.Peppers