(Type your message here)
From: senthil t
There is a third party website that we use=2E Whenever someone=
unsubscribes from our website, some one has to go to that third=
party website, enter the unsubscribed user info and submit the=
form=2E We are doing this manually=2E What I would like is, whenever=
any user unsubscribes from our website, auto post the third=
party website form with all the user information from my =2Enet=
code=2E This is the code I have right now=2E But this is not=
working=2E
HttpWebRequest webRequest =3D (HttpWebRequest) WebRequest=2ECreate=
(URL);
webRequest=2EKeepAlive =3D false;
webRequest=2ETimeout =3D 100000;
webRequest=2EMethod =3D "POST";
webRequest=2EContentType =3D "application/x-www-form-urlencoded";
byte[] requestBytes =3D (new=
System=2EText=2EASCIIEncoding())=2EGetBy
tes (PostData);
webRequest=2EContentLength =3D requestBytes=2ELength;
Stream requestStream =3D webRequest=2EGetRequestStream();
requestStream=2EWrite (requestBytes, 0, requestBytes=2ELength);
requestStream=2EClose();
webResponse =3D (HttpWebResponse) webRequest=2EGetResponse();
sr =3D new StreamReader (webResponse=2EGetResponseStream(),=
System=2EText=2EEncoding=2EASCII);
response =3D sr=2EReadToEnd ();
With =2Easpx page, it was not doing anything until I added the=
viewstate info to the postdata=2E But is throwing an error at this=
line=2E
webResponse =3D (HttpWebResponse) webRequest=2EGetResponse();
Internal Server Error=2ESystem=2ENet=2EHttpWebResponse at=
System=2ENet=2EHttpWebRequest=2ECheckFin
alStatus() at=
System=2ENet=2EHttpWebRequest=2EEndGetRe
sponse(IAsyncResult=
asyncResult) at System=2ENet=2EHttpWebRequest=2EGetRespo
nse()
Can any one tell me what is wrong with what I am doing?
Posted by a user from =2ENET 247 (http://www=2Edotnet247=2Ecom/)
<Id>0ZTNUiUrPECOfo+INVokdg=3D=3D</Id>Hi senthil:
What I've done in the past is use a tool like Fiddler [1] to compare
what my program is POSTing to the server versus what happens when I
use a browser.
http://www.fiddlertool.com/fiddler/
Scott
http://www.OdeToCode.com/blogs/scott/
On Sun, 15 May 2005 05:03:55 -0700, senthil t via .NET 247
<anonymous@.dotnet247.com> wrote:
>(Type your message here)
>--
>From: senthil t
>There is a third party website that we use. Whenever someone unsubscribes from our
website, some one has to go to that third party website, enter the unsubscribed user
info and submit the form. We are doing this manually. What I would like is, wheneve
r a
ny user unsubscribes from our website, auto post the third party website form with all the
user information from my .net code. This is the code I have right now. But this is not work
ing.
> HttpWebRequest webRequest = (HttpWebRequest) WebRequest.Create (URL);
> webRequest.KeepAlive = false;
> webRequest.Timeout = 100000;
> webRequest.Method = "POST";
> webRequest.ContentType = "application/x-www-form-urlencoded";
> byte[] requestBytes = (new System.Text.ASCIIEncoding()).GetBytes (PostDa
ta);
> webRequest.ContentLength = requestBytes.Length;
> Stream requestStream = webRequest.GetRequestStream();
> requestStream.Write (requestBytes, 0, requestBytes.Length);
> requestStream.Close();
> webResponse = (HttpWebResponse) webRequest.GetResponse();
> sr = new StreamReader (webResponse.GetResponseStream(), System.Text.Enco
ding.ASCII);
> response = sr.ReadToEnd ();
>With .aspx page, it was not doing anything until I added the viewstate info
to the postdata. But is throwing an error at this line.
>webResponse = (HttpWebResponse) webRequest.GetResponse();
>Internal Server Error.System.Net.HttpWebResponse at System.Net.HttpWebReque
st.CheckFinalStatus() at System.Net.HttpWebRequest.EndGetResponse(IAsyncResu
lt asyncResult) at System.Net.HttpWebRequest.GetResponse()
>Can any one tell me what is wrong with what I am doing?
>--
>Posted by a user from .NET 247 (http://www.dotnet247.com/)
><Id>0ZTNUiUrPECOfo+INVokdg==</Id>
Showing posts with label httpwebrequest. Show all posts
Showing posts with label httpwebrequest. Show all posts
Monday, March 26, 2012
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" 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/d...rl=/library/en-
us/cpref/html/frlrfSystemNetServicePointManagerClassCertificateP olicyTop
ic.asp
Cheers,
--
Joerg Jooss
joerg.jooss@.gmx.net
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.
> http://msdn.microsoft.com/library/d...rl=/library/en-
> us/cpref/html/frlrfSystemNetServicePointManagerClassCertificateP olicyTop
> ic.asp
> Cheers,
> --
> Joerg Jooss
> joerg.jooss@.gmx.net
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" 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/d...rl=/library/en-
us/cpref/html/frlrfSystemNetServicePointManagerClassCertificateP olicyTop
ic.asp
Cheers,
--
Joerg Jooss
joerg.jooss@.gmx.net
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.
> http://msdn.microsoft.com/library/d...rl=/library/en-
> us/cpref/html/frlrfSystemNetServicePointManagerClassCertificateP olicyTop
> ic.asp
> Cheers,
> --
> Joerg Jooss
> joerg.jooss@.gmx.net
Labels:
asp,
https,
httpwebrequest,
net,
object,
prefixing,
system,
systemnethttpwebrequest,
url,
webpage
Subscribe to:
Posts (Atom)