SSL, please help!

Z

Zen

I have the following sample code, which works fine if the URL is not SSL.
(https)

Once I switch the URL to be SSL, it works fine for the first time, but the
2nd time the function is called, it throws exception when writing data to
request string.

The message from the exception is : "A blocking operation is currently
excuting"

and the Error code for the exception is 10036

(Note: I did install the Root CA on my handheld.)

Appricate all the help!!!

----------------------------------------------------------------------------
------------------------------------

public string MyFunction()

{

HttpWebRequest myRequest;

HttpWebResponse myResponse;

string postData;

Byte[] postBytes;

Stream requestStream;

Stream responseStream;

StreamReader sr;

string fullResponse = "";



myRequest =
(HttpWebRequest)WebRequest.Create(https://server.domain.com/virtualDir/page.
asp);

myRequest.Method = "POST";

//Populate post data

myRequest.ContentLength = postData.Length;

postBytes = Encoding.ASCII.GetBytes(postData);

requestStream = myRequest.GetRequestStream();

requestStream.Write(postBytes, 0, postData.Length); //Exception throw at
the second call: "A blocking operation is currently excuting"

requestStream.Close();


//get response

myResponse = (HttpWebResponse)myRequest.GetResponse();

responseStream = myResponse.GetResponseStream();

sr = new StreamReader(responseStream);

fullResponse = sr.ReadLine();

responseStream.Close();

}
 
M

Mike Boilen [MS]

Instead of setting the ContentLength, you should turn on
AllowWriteStreamBuffering. This works around the bug in the .net CF.

Hope this helps

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: "Zen" <[email protected]>
| Subject: SSL, please help!
| Date: Mon, 11 Aug 2003 16:56:43 -0500
| Lines: 76
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
| Message-ID: <[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.compactframework
| NNTP-Posting-Host: outbound.epicsys.com 12.148.194.126
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP09.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.compactframework:30685
| X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework
|
| I have the following sample code, which works fine if the URL is not SSL.
| (https)
|
| Once I switch the URL to be SSL, it works fine for the first time, but the
| 2nd time the function is called, it throws exception when writing data to
| request string.
|
| The message from the exception is : "A blocking operation is currently
| excuting"
|
| and the Error code for the exception is 10036
|
| (Note: I did install the Root CA on my handheld.)
|
| Appricate all the help!!!
|
|
----------------------------------------------------------------------------
| ------------------------------------
|
| public string MyFunction()
|
| {
|
| HttpWebRequest myRequest;
|
| HttpWebResponse myResponse;
|
| string postData;
|
| Byte[] postBytes;
|
| Stream requestStream;
|
| Stream responseStream;
|
| StreamReader sr;
|
| string fullResponse = "";
|
|
|
| myRequest =
|
(HttpWebRequest)WebRequest.Create(https://server.domain.com/virtualDir/page.
| asp);
|
| myRequest.Method = "POST";
|
| //Populate post data
|
| myRequest.ContentLength = postData.Length;
|
| postBytes = Encoding.ASCII.GetBytes(postData);
|
| requestStream = myRequest.GetRequestStream();
|
| requestStream.Write(postBytes, 0, postData.Length); //Exception throw at
| the second call: "A blocking operation is currently excuting"
|
| requestStream.Close();
|
|
| //get response
|
| myResponse = (HttpWebResponse)myRequest.GetResponse();
|
| responseStream = myResponse.GetResponseStream();
|
| sr = new StreamReader(responseStream);
|
| fullResponse = sr.ReadLine();
|
| responseStream.Close();
|
| }
|
|
|
 

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