System.Net.HttpWebRequest with HTTPS

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default System.Net.HttpWebRequest with HTTPS

    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(pa rams);
    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 Guest

  2. Similar Questions and Discussions

    1. #38631 [Bgs]: fopen('https://...') or curl with https gives Segmentation fault
      ID: 38631 Updated by: darkelder@php.net Reported By: roberto dot berto at gmail dot com Status: Bogus Bug...
    2. httpwebrequest please help clarify
      I am posting an xml document using httpwebrequest post method using a x509certificate, my question is this, is this secure if I am posting to an...
    3. Problem using HttpWebRequest/HttpWebResponse with HTTPS
      Did you ever solve this problem? If so, please can you let me know how as I am trying to do something similar. richard.beacroft@warnerbros.com ...
    4. HttpWebRequest and 401
      Hello All Here is what I am attempting to do: I have a NTLM protected site. There are some users who are not part of the domain (visitors) get...
    5. HTTPWebRequest
      Well, here's the scenario: In your base app, the user's credentials are verified. If the rest of those apps "hang under" the base app, then you...
  3. #2

    Default Re: System.Net.HttpWebRequest with HTTPS

    "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.

    [url]http://msdn.microsoft.com/library/default.asp?url=/library/en-[/url]
    us/cpref/html/frlrfSystemNetServicePointManagerClassCertificateP olicyTop
    ic.asp

    Cheers,
    --
    Joerg Jooss
    [email]joerg.jooss@gmx.net[/email]
    Joerg Jooss Guest

  4. #3

    Default Re: System.Net.HttpWebRequest with HTTPS

    Thanks, Joerg.

    "Joerg Jooss" <joerg.jooss@gmx.net> wrote in message
    news:OfG1RIqTDHA.3132@tk2msftngp13.phx.gbl...
    > "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.
    >
    > [url]http://msdn.microsoft.com/library/default.asp?url=/library/en-[/url]
    > us/cpref/html/frlrfSystemNetServicePointManagerClassCertificateP olicyTop
    > ic.asp
    >
    > Cheers,
    > --
    > Joerg Jooss
    > [email]joerg.jooss@gmx.net[/email]

    dgiard Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139