System.Net.HttpWebRequest with HTTPS

Discussion in 'ASP .Net' started by dgiard, Jul 19, 2003.

  1. dgiard

    dgiard Guest

    I am using the System.Net.HttpWebRequest object to POST data to an HTTPS web
    page.

    Other than prefixing the URL with "HTTPS://", do I need to do anything in my
    code to indicate that this is SSL?

    Here is my code:
    // Create Web Request
    string url = "https://something.net/something.dll";

    HttpWebRequest oHttp =
    (HttpWebRequest) WebRequest.Create(url);

    // Post form variables
    string params = "x_Version=" + version
    + "&x_DelimData=" + delimData
    + "&x_Login=" + login
    + "&x_Password=" + password
    + "&x_Amount=" + amount
    + "&x_Card_Num=" + cardNumber
    + "&x_Exp_Date=" + expirationDate
    + "&x_Type=" + type;
    oHttp.Method="POST";
    byte [] postBuffer =
    System.Text.Encoding.GetEncoding(1252).GetBytes(params);
    oHttp.ContentLength = postBuffer.Length;
    Stream postData = oHttp.GetRequestStream();
    postData.Write(postBuffer,0,postBuffer.Length);
    postData.Close();

    // Get results
    HttpWebResponse myResponse = (HttpWebResponse) oHttp.GetResponse();
    Encoding enc = System.Text.Encoding.GetEncoding(1252);
    StreamReader loResponseStream =
    new StreamReader(myResponse.GetResponseStream(), enc);
    string retHtml = loResponseStream.ReadToEnd();
    myResponse.Close();
    loResponseStream.Close();

    messages = retHtml;
    dgiard, Jul 19, 2003
    #1
    1. Advertising

  2. dgiard

    Joerg Jooss Guest

    "dgiard" spoke:

    > I am using the System.Net.HttpWebRequest object to POST data to an
    > HTTPS web page.
    >
    > Other than prefixing the URL with "HTTPS://", do I need to do
    > anything in my code to indicate that this is SSL?


    Check out if the framework's default certificate policy (URL below)
    works for you. If not, you need to implement your own. But that should
    be it.

    http://msdn.microsoft.com/library/default.asp?url=/library/en-
    us/cpref/html/frlrfSystemNetServicePointManagerClassCertificatePolicyTop
    ic.asp

    Cheers,
    --
    Joerg Jooss
    Joerg Jooss, Jul 20, 2003
    #2
    1. Advertising

  3. dgiard

    dgiard Guest

    Thanks, Joerg.

    "Joerg Jooss" <> wrote in message
    news:...
    > "dgiard" spoke:
    >
    > > I am using the System.Net.HttpWebRequest object to POST data to an
    > > HTTPS web page.
    > >
    > > Other than prefixing the URL with "HTTPS://", do I need to do
    > > anything in my code to indicate that this is SSL?

    >
    > Check out if the framework's default certificate policy (URL below)
    > works for you. If not, you need to implement your own. But that should
    > be it.
    >
    > http://msdn.microsoft.com/library/default.asp?url=/library/en-
    > us/cpref/html/frlrfSystemNetServicePointManagerClassCertificatePolicyTop
    > ic.asp
    >
    > Cheers,
    > --
    > Joerg Jooss
    >
    dgiard, Jul 20, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Greg Reevosh via .NET 247

    Issue with System.Net.HttpWebRequest

    Greg Reevosh via .NET 247, Oct 17, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    4,384
    Feroze [msft]
    Oct 22, 2004
  2. Keith Patrick
    Replies:
    11
    Views:
    14,831
    Scott Allen
    Feb 22, 2005
  3. Lenster
    Replies:
    4
    Views:
    1,253
    bruce barker
    Dec 4, 2008
  4. Ken Fine
    Replies:
    2
    Views:
    584
    Steven Cheng
    Sep 17, 2008
  5. jotto
    Replies:
    4
    Views:
    381
    jotto
    Oct 2, 2006
Loading...

Share This Page