473,382 Members | 1,425 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

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;
Nov 17 '05 #1
2 20070
"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/de...l=/library/en-
us/cpref/html/frlrfSystemNetServicePointManagerClassCertificateP olicyTop
ic.asp

Cheers,
--
Joerg Jooss
jo*********@gmx.net
Nov 17 '05 #2
Thanks, Joerg.

"Joerg Jooss" <jo*********@gmx.net> wrote in message
news:Of**************@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.

http://msdn.microsoft.com/library/de...l=/library/en-
us/cpref/html/frlrfSystemNetServicePointManagerClassCertificateP olicyTop
ic.asp

Cheers,
--
Joerg Jooss
jo*********@gmx.net

Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Mackuack | last post by:
Hello everybody i have the following code to access an application via https: --------------------------------------------- System.Net.ServicePointManager.CertificatePolicy = new...
4
by: Steven Pu | last post by:
Hi, Specifically, the website I am trying to access is, https://gmail.google.com/ I've read elsewhere that Google only uses SSL2, while .NET uses SSL3 and is not backward compatible. Is...
0
by: Kumar | last post by:
Hi all, I have the following code which uses WebClient.UploadValues myNameValueCollection.Add("Name", name) myNameValueCollection.Add("Age", age) .............. ............. Dim web As New...
1
by: Dave Brown | last post by:
I am attempting to post to a url (https://FakeURL/logon.asp) using the HttpWebRequest class. The response for a succesful post will contain the html for the logon user's default page. We've...
0
by: msnews.microsoft.com | last post by:
I have been raking my brains on why this does not work. I get back the same login screen again instead of the home page redirection which should occur after a successful login: 'create a cookie...
0
by: phil.jacobs | last post by:
Hi there, I am very stuck and have tried everything on this one! I am trying to get to an https website and cannot work out how to logon. When I log on manually, I have to enter username and...
6
by: nganapat | last post by:
I am trying to post form values to a https web page programmatically using Httpwebrequest but no matter what I do the same login page is returned instead of the next page. I would very much...
2
by: =?Utf-8?B?cmVk?= | last post by:
Hi Friends, We recently deployed our application to production and I am experiencing the below error message. Cannot access a disposed object named "System.Net.TlsStream" The error occurs...
0
by: =?Utf-8?B?RGFuaQ==?= | last post by:
Hi. I'm using this code to access an https service: public class AcceptAllCertificatePolicy : ICertificatePolicy { public bool CheckValidationResult(ServicePoint srvPoint, X509Certificate...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.