A Way to specify a port on WebRequest.Create()?

Y

Young Cho

Hi,

I am trying to POST XML data to my web server via HTTPS and port 5000. I am
specifying the port number on a WebRequest.Create call as code below. From
what I am seeing, this does not seem to be working. Can I specify a port
number on the WebRequest.Create() call? If so, is my syntax correct?

Thank you.
Young.

HttpWebRequest req =
(HttpWebRequest)WebRequest.Create(https://myserver:5000);

req.Method = "POST";

req.ContentType = "text/xml";

req.Headers.Add("Cookie: SMCHALLENGE=YES");

req.Headers.Add("Authorization: Basic " + authStr);



byte[] encodedBytes = Encoding.UTF8.GetBytes(deliveryPackage.Payload);

req.ContentLength = encodedBytes.Length;




requestStream = req.GetRequestStream();
 
M

Mike Boilen [MS]

Your problem has nothing to do with specifying the port. You've
encountered a bug in the Compact Framework with the way you're using ssl
and HttpWebRequest. Instead of setting the ContentLength on the request,
set AllowWriteStreamBuffering to true. Try your request like that, and you
should have success.

Mike Boilen
Developer
.NET Compact Framework

This posting is provided "AS IS" with no warranties, and confers no rights.
http://www.gotdotnet.com/team/netcf/FAQ.aspx

--------------------
| From: "Young Cho" <[email protected]>
| Subject: A Way to specify a port on WebRequest.Create()?
| Date: Wed, 22 Oct 2003 14:05:34 -0700
| Lines: 33
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.compactframework
| NNTP-Posting-Host: ycho.qualcomm.com 129.46.148.47
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.compactframework:36614
| X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework
|
| Hi,
|
| I am trying to POST XML data to my web server via HTTPS and port 5000. I
am
| specifying the port number on a WebRequest.Create call as code below.
From
| what I am seeing, this does not seem to be working. Can I specify a port
| number on the WebRequest.Create() call? If so, is my syntax correct?
|
| Thank you.
| Young.
|
| HttpWebRequest req =
| (HttpWebRequest)WebRequest.Create(https://myserver:5000);
|
| req.Method = "POST";
|
| req.ContentType = "text/xml";
|
| req.Headers.Add("Cookie: SMCHALLENGE=YES");
|
| req.Headers.Add("Authorization: Basic " + authStr);
|
|
|
| byte[] encodedBytes = Encoding.UTF8.GetBytes(deliveryPackage.Payload);
|
| req.ContentLength = encodedBytes.Length;
|
|
|
|
| requestStream = req.GetRequestStream();
|
|
|
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top