Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Services > C# Zip

Reply
Thread Tools

C# Zip

 
 
Aung
Guest
Posts: n/a
 
      08-24-2003
Has anybody develop RFC1950 and RFC1951 compliant Zip utility?

Any pointer will be appreciated.



 
Reply With Quote
 
 
 
 
Pieter Philippaerts
Guest
Posts: n/a
 
      08-25-2003
"Aung" <aung@aungkyawmoe_NOSPAM_.net> wrote in message
news:(E-Mail Removed)...
> Has anybody develop RFC1950 and RFC1951 compliant Zip utility?
> Any pointer will be appreciated.


http://www.icsharpcode.net/OpenSource/SharpZipLib/

Regards,
Pieter Philippaerts
Managed SSL/TLS: http://www.mentalis.org/go.php?sl


 
Reply With Quote
 
 
 
 
Aung
Guest
Posts: n/a
 
      08-29-2003
Hello,

I am having a problem with WebRequest class. I used the following code to
post some data to a page and retrive back the response. It works fine with
http:// connection. When i use that with https:// connection, it thrown an
exception "The underlying connection was closed: Could not establish trust
relationship with remote server.". I am using self sign certificate on the
web server and the root and CA certificates are installed on the client
machine using the following code.

your suggestions will be great appreciated.

Aung

public string postForm(string url, string postData)

{

string retStr="", tempStr;

HttpWebResponse result = null;

try

{

HttpWebRequest req = (HttpWebRequest) WebRequest.Create(url);

req.Method = "POST";

req.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR
1.0.3705)";

req.ContentType = "application/x-www-form-urlencoded";

StringBuilder UrlEncoded = new StringBuilder();

Char[] reserved = {'?', '=', '&'};

byte[] SomeBytes = null;

if (postData != null)

{

int i=0, j;

while(i<postData.Length)

{

j=postData.IndexOfAny(reserved, i);

if (j==-1)

{

UrlEncoded.Append(HttpUtility.UrlEncode(postData.S ubstring(i,
postData.Length-i)));

break;

}

UrlEncoded.Append(HttpUtility.UrlEncode(postData.S ubstring(i, j-i)));

UrlEncoded.Append(postData.Substring(j,1));

i = j+1;

}

SomeBytes = Encoding.UTF8.GetBytes(UrlEncoded.ToString());

req.ContentLength = SomeBytes.Length;

Stream newStream = req.GetRequestStream();

newStream.Write(SomeBytes, 0, SomeBytes.Length);

newStream.Close();

}

else

{

req.ContentLength = 0;

}

result = (HttpWebResponse) req.GetResponse();

Stream ReceiveStream = result.GetResponseStream();

Encoding encode = System.Text.Encoding.GetEncoding("utf-8");

StreamReader sr = new StreamReader( ReceiveStream, encode );

Char[] read = new Char[256];

int count = sr.Read( read, 0, 256 );

while (count > 0)

{

tempStr = new String(read, 0, count);

retStr += tempStr;

count = sr.Read(read, 0, 256);

}

retStr.Trim();

}

catch (Exception e)

{

retStr = "Error!!";

}

finally

{

if ( result != null )

{

result.Close();

}

}

return retStr;

}



 
Reply With Quote
 
Justin Rogers
Guest
Posts: n/a
 
      08-29-2003
Best way to test your client is see if you can do the same from IE. Most of
the System.Net classes take configuration from IE behind the scenes. If it
doesn't work in IE and you do get it working, make sure to close all
instances of IE so the data persists before re-running the .NET application.
Some changes are considered dynamic and won't be written to the registry
until close.

Hopefully you find that IE won't connect either. I find it hard to believe
that .NET would have a more stringent implementation of SSL than IE. But it
is possible.

--
Justin Rogers
DigiTec Web Consultants, LLC.

"Aung" <aung@aungkyawmoe_NOSPAM_.net> wrote in message
news:(E-Mail Removed)...
> Hello,
>
> I am having a problem with WebRequest class. I used the following code to
> post some data to a page and retrive back the response. It works fine with
> http:// connection. When i use that with https:// connection, it thrown an
> exception "The underlying connection was closed: Could not establish trust
> relationship with remote server.". I am using self sign certificate on the
> web server and the root and CA certificates are installed on the client
> machine using the following code.
>
> your suggestions will be great appreciated.
>
> Aung
>
> public string postForm(string url, string postData)
>
> {
>
> string retStr="", tempStr;
>
> HttpWebResponse result = null;
>
> try
>
> {
>
> HttpWebRequest req = (HttpWebRequest) WebRequest.Create(url);
>
> req.Method = "POST";
>
> req.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET

CLR
> 1.0.3705)";
>
> req.ContentType = "application/x-www-form-urlencoded";
>
> StringBuilder UrlEncoded = new StringBuilder();
>
> Char[] reserved = {'?', '=', '&'};
>
> byte[] SomeBytes = null;
>
> if (postData != null)
>
> {
>
> int i=0, j;
>
> while(i<postData.Length)
>
> {
>
> j=postData.IndexOfAny(reserved, i);
>
> if (j==-1)
>
> {
>
> UrlEncoded.Append(HttpUtility.UrlEncode(postData.S ubstring(i,
> postData.Length-i)));
>
> break;
>
> }
>
> UrlEncoded.Append(HttpUtility.UrlEncode(postData.S ubstring(i, j-i)));
>
> UrlEncoded.Append(postData.Substring(j,1));
>
> i = j+1;
>
> }
>
> SomeBytes = Encoding.UTF8.GetBytes(UrlEncoded.ToString());
>
> req.ContentLength = SomeBytes.Length;
>
> Stream newStream = req.GetRequestStream();
>
> newStream.Write(SomeBytes, 0, SomeBytes.Length);
>
> newStream.Close();
>
> }
>
> else
>
> {
>
> req.ContentLength = 0;
>
> }
>
> result = (HttpWebResponse) req.GetResponse();
>
> Stream ReceiveStream = result.GetResponseStream();
>
> Encoding encode = System.Text.Encoding.GetEncoding("utf-8");
>
> StreamReader sr = new StreamReader( ReceiveStream, encode );
>
> Char[] read = new Char[256];
>
> int count = sr.Read( read, 0, 256 );
>
> while (count > 0)
>
> {
>
> tempStr = new String(read, 0, count);
>
> retStr += tempStr;
>
> count = sr.Read(read, 0, 256);
>
> }
>
> retStr.Trim();
>
> }
>
> catch (Exception e)
>
> {
>
> retStr = "Error!!";
>
> }
>
> finally
>
> {
>
> if ( result != null )
>
> {
>
> result.Close();
>
> }
>
> }
>
> return retStr;
>
> }
>
>
>



 
Reply With Quote
 
Joe Kaplan \(MVP - ADSI\)
Guest
Posts: n/a
 
      08-29-2003
A thing that I have found that can help is to implement a class based on
ICertificatePolicy that handles the CheckValidationResult method. If you
set an instance of your class to the ServicePointManager.CertificatePolicy
property, you can override the behavior of certificate handling errors.
Returning true will cause the system to ignore all errors, which is
sometimes helpful for testing (but a bad a idea for production code).

HTH,

Joe K.

"Justin Rogers" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Best way to test your client is see if you can do the same from IE. Most

of
> the System.Net classes take configuration from IE behind the scenes. If

it
> doesn't work in IE and you do get it working, make sure to close all
> instances of IE so the data persists before re-running the .NET

application.
> Some changes are considered dynamic and won't be written to the registry
> until close.
>
> Hopefully you find that IE won't connect either. I find it hard to

believe
> that .NET would have a more stringent implementation of SSL than IE. But

it
> is possible.
>
> --
> Justin Rogers
> DigiTec Web Consultants, LLC.
>
> "Aung" <aung@aungkyawmoe_NOSPAM_.net> wrote in message
> news:(E-Mail Removed)...
> > Hello,
> >
> > I am having a problem with WebRequest class. I used the following code

to
> > post some data to a page and retrive back the response. It works fine

with
> > http:// connection. When i use that with https:// connection, it thrown

an
> > exception "The underlying connection was closed: Could not establish

trust
> > relationship with remote server.". I am using self sign certificate on

the
> > web server and the root and CA certificates are installed on the client
> > machine using the following code.
> >
> > your suggestions will be great appreciated.
> >
> > Aung
> >
> > public string postForm(string url, string postData)
> >
> > {
> >
> > string retStr="", tempStr;
> >
> > HttpWebResponse result = null;
> >
> > try
> >
> > {
> >
> > HttpWebRequest req = (HttpWebRequest) WebRequest.Create(url);
> >
> > req.Method = "POST";
> >
> > req.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET

> CLR
> > 1.0.3705)";
> >
> > req.ContentType = "application/x-www-form-urlencoded";
> >
> > StringBuilder UrlEncoded = new StringBuilder();
> >
> > Char[] reserved = {'?', '=', '&'};
> >
> > byte[] SomeBytes = null;
> >
> > if (postData != null)
> >
> > {
> >
> > int i=0, j;
> >
> > while(i<postData.Length)
> >
> > {
> >
> > j=postData.IndexOfAny(reserved, i);
> >
> > if (j==-1)
> >
> > {
> >
> > UrlEncoded.Append(HttpUtility.UrlEncode(postData.S ubstring(i,
> > postData.Length-i)));
> >
> > break;
> >
> > }
> >
> > UrlEncoded.Append(HttpUtility.UrlEncode(postData.S ubstring(i, j-i)));
> >
> > UrlEncoded.Append(postData.Substring(j,1));
> >
> > i = j+1;
> >
> > }
> >
> > SomeBytes = Encoding.UTF8.GetBytes(UrlEncoded.ToString());
> >
> > req.ContentLength = SomeBytes.Length;
> >
> > Stream newStream = req.GetRequestStream();
> >
> > newStream.Write(SomeBytes, 0, SomeBytes.Length);
> >
> > newStream.Close();
> >
> > }
> >
> > else
> >
> > {
> >
> > req.ContentLength = 0;
> >
> > }
> >
> > result = (HttpWebResponse) req.GetResponse();
> >
> > Stream ReceiveStream = result.GetResponseStream();
> >
> > Encoding encode = System.Text.Encoding.GetEncoding("utf-8");
> >
> > StreamReader sr = new StreamReader( ReceiveStream, encode );
> >
> > Char[] read = new Char[256];
> >
> > int count = sr.Read( read, 0, 256 );
> >
> > while (count > 0)
> >
> > {
> >
> > tempStr = new String(read, 0, count);
> >
> > retStr += tempStr;
> >
> > count = sr.Read(read, 0, 256);
> >
> > }
> >
> > retStr.Trim();
> >
> > }
> >
> > catch (Exception e)
> >
> > {
> >
> > retStr = "Error!!";
> >
> > }
> >
> > finally
> >
> > {
> >
> > if ( result != null )
> >
> > {
> >
> > result.Close();
> >
> > }
> >
> > }
> >
> > return retStr;
> >
> > }
> >
> >
> >

>
>



 
Reply With Quote
 
Drebin
Guest
Posts: n/a
 
      08-30-2003
Egads!! BAD cross-poster - BAD!!

Anyhow, yes - this is exactly what the problem is. You can't programatically
specify a trust list (at least I haven't run across a way) - so even if you
log in with that account, and add the certificate authority -
programatically - it will still not trust that CA.

The ONLY way I've seen this or been able to get this to work (because I
needed to do the same thing) - is you have to get real certificates, like
from Verisign or Thawte..


"Aung" <aung@aungkyawmoe_NOSPAM_.net> wrote in message
news:(E-Mail Removed)...
> Yes. i used IE before calling from my application. IE popup with a warning
> message telling me that "certificate on the server is not the same name

bla
> bla. " and when i hit OK, i can view the SSL page with form.
>
> my .NET application cannot.
>
>
> "Justin Rogers" <(E-Mail Removed)> wrote in message
> news:#(E-Mail Removed)...
> > Best way to test your client is see if you can do the same from IE.

Most
> of
> > the System.Net classes take configuration from IE behind the scenes. If

> it
> > doesn't work in IE and you do get it working, make sure to close all
> > instances of IE so the data persists before re-running the .NET

> application.
> > Some changes are considered dynamic and won't be written to the registry
> > until close.
> >
> > Hopefully you find that IE won't connect either. I find it hard to

> believe
> > that .NET would have a more stringent implementation of SSL than IE.

But
> it
> > is possible.
> >
> > --
> > Justin Rogers
> > DigiTec Web Consultants, LLC.
> >
> > "Aung" <aung@aungkyawmoe_NOSPAM_.net> wrote in message
> > news:(E-Mail Removed)...
> > > Hello,
> > >
> > > I am having a problem with WebRequest class. I used the following code

> to
> > > post some data to a page and retrive back the response. It works fine

> with
> > > http:// connection. When i use that with https:// connection, it

thrown
> an
> > > exception "The underlying connection was closed: Could not establish

> trust
> > > relationship with remote server.". I am using self sign certificate on

> the
> > > web server and the root and CA certificates are installed on the

client
> > > machine using the following code.
> > >
> > > your suggestions will be great appreciated.
> > >
> > > Aung
> > >
> > > public string postForm(string url, string postData)
> > >
> > > {
> > >
> > > string retStr="", tempStr;
> > >
> > > HttpWebResponse result = null;
> > >
> > > try
> > >
> > > {
> > >
> > > HttpWebRequest req = (HttpWebRequest) WebRequest.Create(url);
> > >
> > > req.Method = "POST";
> > >
> > > req.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;

..NET
> > CLR
> > > 1.0.3705)";
> > >
> > > req.ContentType = "application/x-www-form-urlencoded";
> > >
> > > StringBuilder UrlEncoded = new StringBuilder();
> > >
> > > Char[] reserved = {'?', '=', '&'};
> > >
> > > byte[] SomeBytes = null;
> > >
> > > if (postData != null)
> > >
> > > {
> > >
> > > int i=0, j;
> > >
> > > while(i<postData.Length)
> > >
> > > {
> > >
> > > j=postData.IndexOfAny(reserved, i);
> > >
> > > if (j==-1)
> > >
> > > {
> > >
> > > UrlEncoded.Append(HttpUtility.UrlEncode(postData.S ubstring(i,
> > > postData.Length-i)));
> > >
> > > break;
> > >
> > > }
> > >
> > > UrlEncoded.Append(HttpUtility.UrlEncode(postData.S ubstring(i, j-i)));
> > >
> > > UrlEncoded.Append(postData.Substring(j,1));
> > >
> > > i = j+1;
> > >
> > > }
> > >
> > > SomeBytes = Encoding.UTF8.GetBytes(UrlEncoded.ToString());
> > >
> > > req.ContentLength = SomeBytes.Length;
> > >
> > > Stream newStream = req.GetRequestStream();
> > >
> > > newStream.Write(SomeBytes, 0, SomeBytes.Length);
> > >
> > > newStream.Close();
> > >
> > > }
> > >
> > > else
> > >
> > > {
> > >
> > > req.ContentLength = 0;
> > >
> > > }
> > >
> > > result = (HttpWebResponse) req.GetResponse();
> > >
> > > Stream ReceiveStream = result.GetResponseStream();
> > >
> > > Encoding encode = System.Text.Encoding.GetEncoding("utf-8");
> > >
> > > StreamReader sr = new StreamReader( ReceiveStream, encode );
> > >
> > > Char[] read = new Char[256];
> > >
> > > int count = sr.Read( read, 0, 256 );
> > >
> > > while (count > 0)
> > >
> > > {
> > >
> > > tempStr = new String(read, 0, count);
> > >
> > > retStr += tempStr;
> > >
> > > count = sr.Read(read, 0, 256);
> > >
> > > }
> > >
> > > retStr.Trim();
> > >
> > > }
> > >
> > > catch (Exception e)
> > >
> > > {
> > >
> > > retStr = "Error!!";
> > >
> > > }
> > >
> > > finally
> > >
> > > {
> > >
> > > if ( result != null )
> > >
> > > {
> > >
> > > result.Close();
> > >
> > > }
> > >
> > > }
> > >
> > > return retStr;
> > >
> > > }
> > >
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
Tim Cartwright
Guest
Posts: n/a
 
      09-04-2003
I was having the same issue using a MS Certificate Server . If you are using
you
own certificate authority to issue the certificate the problem lies in the
fact
that your client computer does not trust the issuing certificate authority.
Read
the section "Install Your Certification Authority's Certificate on the
Client"
from http://support.microsoft.com/default...b;en-us;324284 IE gives
you
the option to accept this discrepancy, but .net does not.

Tim Cartwright //Will write code for food


"Drebin" <(E-Mail Removed)> wrote in message
news:ZIS3b.2862$(E-Mail Removed) m...
> Egads!! BAD cross-poster - BAD!!
>
> Anyhow, yes - this is exactly what the problem is. You can't

programatically
> specify a trust list (at least I haven't run across a way) - so even if

you
> log in with that account, and add the certificate authority -
> programatically - it will still not trust that CA.
>
> The ONLY way I've seen this or been able to get this to work (because I
> needed to do the same thing) - is you have to get real certificates, like
> from Verisign or Thawte..
>
>
> "Aung" <aung@aungkyawmoe_NOSPAM_.net> wrote in message
> news:(E-Mail Removed)...
> > Yes. i used IE before calling from my application. IE popup with a

warning
> > message telling me that "certificate on the server is not the same name

> bla
> > bla. " and when i hit OK, i can view the SSL page with form.
> >
> > my .NET application cannot.
> >
> >
> > "Justin Rogers" <(E-Mail Removed)> wrote in message
> > news:#(E-Mail Removed)...
> > > Best way to test your client is see if you can do the same from IE.

> Most
> > of
> > > the System.Net classes take configuration from IE behind the scenes.

If
> > it
> > > doesn't work in IE and you do get it working, make sure to close all
> > > instances of IE so the data persists before re-running the .NET

> > application.
> > > Some changes are considered dynamic and won't be written to the

registry
> > > until close.
> > >
> > > Hopefully you find that IE won't connect either. I find it hard to

> > believe
> > > that .NET would have a more stringent implementation of SSL than IE.

> But
> > it
> > > is possible.
> > >
> > > --
> > > Justin Rogers
> > > DigiTec Web Consultants, LLC.
> > >
> > > "Aung" <aung@aungkyawmoe_NOSPAM_.net> wrote in message
> > > news:(E-Mail Removed)...
> > > > Hello,
> > > >
> > > > I am having a problem with WebRequest class. I used the following

code
> > to
> > > > post some data to a page and retrive back the response. It works

fine
> > with
> > > > http:// connection. When i use that with https:// connection, it

> thrown
> > an
> > > > exception "The underlying connection was closed: Could not establish

> > trust
> > > > relationship with remote server.". I am using self sign certificate

on
> > the
> > > > web server and the root and CA certificates are installed on the

> client
> > > > machine using the following code.
> > > >
> > > > your suggestions will be great appreciated.
> > > >
> > > > Aung
> > > >
> > > > public string postForm(string url, string postData)
> > > >
> > > > {
> > > >
> > > > string retStr="", tempStr;
> > > >
> > > > HttpWebResponse result = null;
> > > >
> > > > try
> > > >
> > > > {
> > > >
> > > > HttpWebRequest req = (HttpWebRequest) WebRequest.Create(url);
> > > >
> > > > req.Method = "POST";
> > > >
> > > > req.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;

> .NET
> > > CLR
> > > > 1.0.3705)";
> > > >
> > > > req.ContentType = "application/x-www-form-urlencoded";
> > > >
> > > > StringBuilder UrlEncoded = new StringBuilder();
> > > >
> > > > Char[] reserved = {'?', '=', '&'};
> > > >
> > > > byte[] SomeBytes = null;
> > > >
> > > > if (postData != null)
> > > >
> > > > {
> > > >
> > > > int i=0, j;
> > > >
> > > > while(i<postData.Length)
> > > >
> > > > {
> > > >
> > > > j=postData.IndexOfAny(reserved, i);
> > > >
> > > > if (j==-1)
> > > >
> > > > {
> > > >
> > > > UrlEncoded.Append(HttpUtility.UrlEncode(postData.S ubstring(i,
> > > > postData.Length-i)));
> > > >
> > > > break;
> > > >
> > > > }
> > > >
> > > > UrlEncoded.Append(HttpUtility.UrlEncode(postData.S ubstring(i,

j-i)));
> > > >
> > > > UrlEncoded.Append(postData.Substring(j,1));
> > > >
> > > > i = j+1;
> > > >
> > > > }
> > > >
> > > > SomeBytes = Encoding.UTF8.GetBytes(UrlEncoded.ToString());
> > > >
> > > > req.ContentLength = SomeBytes.Length;
> > > >
> > > > Stream newStream = req.GetRequestStream();
> > > >
> > > > newStream.Write(SomeBytes, 0, SomeBytes.Length);
> > > >
> > > > newStream.Close();
> > > >
> > > > }
> > > >
> > > > else
> > > >
> > > > {
> > > >
> > > > req.ContentLength = 0;
> > > >
> > > > }
> > > >
> > > > result = (HttpWebResponse) req.GetResponse();
> > > >
> > > > Stream ReceiveStream = result.GetResponseStream();
> > > >
> > > > Encoding encode = System.Text.Encoding.GetEncoding("utf-8");
> > > >
> > > > StreamReader sr = new StreamReader( ReceiveStream, encode );
> > > >
> > > > Char[] read = new Char[256];
> > > >
> > > > int count = sr.Read( read, 0, 256 );
> > > >
> > > > while (count > 0)
> > > >
> > > > {
> > > >
> > > > tempStr = new String(read, 0, count);
> > > >
> > > > retStr += tempStr;
> > > >
> > > > count = sr.Read(read, 0, 256);
> > > >
> > > > }
> > > >
> > > > retStr.Trim();
> > > >
> > > > }
> > > >
> > > > catch (Exception e)
> > > >
> > > > {
> > > >
> > > > retStr = "Error!!";
> > > >
> > > > }
> > > >
> > > > finally
> > > >
> > > > {
> > > >
> > > > if ( result != null )
> > > >
> > > > {
> > > >
> > > > result.Close();
> > > >
> > > > }
> > > >
> > > > }
> > > >
> > > > return retStr;
> > > >
> > > > }
> > > >
> > > >
> > > >
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
Franco Gustavo
Guest
Posts: n/a
 
      09-26-2003
I was trying to do that a few months ago and I still need it.
I didn't resolve the problem, I have my own certificates.
May you show what you did?

Thanks,
Gustavo.


"Joe Kaplan (MVP - ADSI)" <(E-Mail Removed)> wrote
in message news:(E-Mail Removed)...
> A thing that I have found that can help is to implement a class based on
> ICertificatePolicy that handles the CheckValidationResult method. If you
> set an instance of your class to the ServicePointManager.CertificatePolicy
> property, you can override the behavior of certificate handling errors.
> Returning true will cause the system to ignore all errors, which is
> sometimes helpful for testing (but a bad a idea for production code).
>
> HTH,
>
> Joe K.
>
> "Justin Rogers" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
> > Best way to test your client is see if you can do the same from IE.

Most
> of
> > the System.Net classes take configuration from IE behind the scenes. If

> it
> > doesn't work in IE and you do get it working, make sure to close all
> > instances of IE so the data persists before re-running the .NET

> application.
> > Some changes are considered dynamic and won't be written to the registry
> > until close.
> >
> > Hopefully you find that IE won't connect either. I find it hard to

> believe
> > that .NET would have a more stringent implementation of SSL than IE.

But
> it
> > is possible.
> >
> > --
> > Justin Rogers
> > DigiTec Web Consultants, LLC.
> >
> > "Aung" <aung@aungkyawmoe_NOSPAM_.net> wrote in message
> > news:(E-Mail Removed)...
> > > Hello,
> > >
> > > I am having a problem with WebRequest class. I used the following code

> to
> > > post some data to a page and retrive back the response. It works fine

> with
> > > http:// connection. When i use that with https:// connection, it

thrown
> an
> > > exception "The underlying connection was closed: Could not establish

> trust
> > > relationship with remote server.". I am using self sign certificate on

> the
> > > web server and the root and CA certificates are installed on the

client
> > > machine using the following code.
> > >
> > > your suggestions will be great appreciated.
> > >
> > > Aung
> > >
> > > public string postForm(string url, string postData)
> > >
> > > {
> > >
> > > string retStr="", tempStr;
> > >
> > > HttpWebResponse result = null;
> > >
> > > try
> > >
> > > {
> > >
> > > HttpWebRequest req = (HttpWebRequest) WebRequest.Create(url);
> > >
> > > req.Method = "POST";
> > >
> > > req.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;

..NET
> > CLR
> > > 1.0.3705)";
> > >
> > > req.ContentType = "application/x-www-form-urlencoded";
> > >
> > > StringBuilder UrlEncoded = new StringBuilder();
> > >
> > > Char[] reserved = {'?', '=', '&'};
> > >
> > > byte[] SomeBytes = null;
> > >
> > > if (postData != null)
> > >
> > > {
> > >
> > > int i=0, j;
> > >
> > > while(i<postData.Length)
> > >
> > > {
> > >
> > > j=postData.IndexOfAny(reserved, i);
> > >
> > > if (j==-1)
> > >
> > > {
> > >
> > > UrlEncoded.Append(HttpUtility.UrlEncode(postData.S ubstring(i,
> > > postData.Length-i)));
> > >
> > > break;
> > >
> > > }
> > >
> > > UrlEncoded.Append(HttpUtility.UrlEncode(postData.S ubstring(i, j-i)));
> > >
> > > UrlEncoded.Append(postData.Substring(j,1));
> > >
> > > i = j+1;
> > >
> > > }
> > >
> > > SomeBytes = Encoding.UTF8.GetBytes(UrlEncoded.ToString());
> > >
> > > req.ContentLength = SomeBytes.Length;
> > >
> > > Stream newStream = req.GetRequestStream();
> > >
> > > newStream.Write(SomeBytes, 0, SomeBytes.Length);
> > >
> > > newStream.Close();
> > >
> > > }
> > >
> > > else
> > >
> > > {
> > >
> > > req.ContentLength = 0;
> > >
> > > }
> > >
> > > result = (HttpWebResponse) req.GetResponse();
> > >
> > > Stream ReceiveStream = result.GetResponseStream();
> > >
> > > Encoding encode = System.Text.Encoding.GetEncoding("utf-8");
> > >
> > > StreamReader sr = new StreamReader( ReceiveStream, encode );
> > >
> > > Char[] read = new Char[256];
> > >
> > > int count = sr.Read( read, 0, 256 );
> > >
> > > while (count > 0)
> > >
> > > {
> > >
> > > tempStr = new String(read, 0, count);
> > >
> > > retStr += tempStr;
> > >
> > > count = sr.Read(read, 0, 256);
> > >
> > > }
> > >
> > > retStr.Trim();
> > >
> > > }
> > >
> > > catch (Exception e)
> > >
> > > {
> > >
> > > retStr = "Error!!";
> > >
> > > }
> > >
> > > finally
> > >
> > > {
> > >
> > > if ( result != null )
> > >
> > > {
> > >
> > > result.Close();
> > >
> > > }
> > >
> > > }
> > >
> > > return retStr;
> > >
> > > }
> > >
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Possibility to add a zip-file to a new zip-file with "add to zip" (right-click) ?? erikkie@casema.nl Computer Support 4 06-26-2006 12:18 AM
uploading and receiving zip file(java.util.zip) ? sunil_varma Java 1 02-06-2006 10:37 AM
java.util.zip.ZipException: error in opening zip file HARI OM Java 0 05-03-2005 05:02 PM
java.util.zip.ZipException: error in opening zip file hari_om@hotmail.com Java 0 05-03-2005 04:47 PM
java.util.zip - problem opening some legitimite me zip files Alex Hunsley Java 1 09-16-2004 02:06 PM



Advertisments