You shouldn't have to "convert" the value unless you are generating it in the first place, which I don't think you are doing.

I just went through this exercise, and (in our case, at least) __VIEWSTATE is only necessary when posting a secondary form after you are already logged in, not in the original login form. And when posting a secondary form, you must use the __VIEWSTATE that is already encoded in the form source. You should not be generating a new one.

Check out http://wiki.apache.org/jakarta-httpclient/ForAbsoluteBeginners for instructions on how to post a form with HttpClient. I think IIS always redirects after a login, so read http://jakarta.apache.org/commons/httpclient/redirects.html as well.

From: "Julius Davies" <[EMAIL PROTECTED]>
Reply-To: "HttpClient User Discussion" <[email protected]>
To: "HttpClient User Discussion" <[email protected]>
Subject: Re: PostMethod - parameter in BASE64String
Date: Wed, 6 Dec 2006 09:05:11 -0500

import org.apache.commons.codec.binary.Base64;

byte[] bytes = "I love my byte array".getBytes();
byte[] base64Bytes = Base64.encodeBase64( bytes );

System.out.println( new String( base64Bytes ) );
Outputs:

SSBsb3ZlIG15IGJ5dGUgYXJyYXk=

Good luck!  Like Roland said, "commons-codec.jar" is already on your
classpath.  The Base64 class is available for you to use.

yours,

Julius


On 12/6/06, Roland Weber <[EMAIL PROTECTED]> wrote:

Hello Marcelo,

it is not the same encoding used in URLs.
HttpClient does not have a Base64 encoder,
but it uses commons-codec for this purpose.

hope that helps,
  Roland

"Marcelo Chryssovergis" <[EMAIL PROTECTED]> wrote on 06.12.2006
15:16:46:

> Hello,
>
> I´m trying to login to a asp.net site.
>
> I´m using the postmethod to send the data, but one of the fields of
> the framework .Net (VIEWSTATE) has to be converted in a
> Base64String. I believe that´s the same encoding used in URLs.
>
> Is there any function in httpclient to encode the string to base64?
>
> Thanks,
> Marcelo





--
yours,

Julius Davies
416-652-0183
http://juliusdavies.ca/

_________________________________________________________________
All-in-one security and maintenance for your PC.  Get a free 90-day trial! http://clk.atdmt.com/MSN/go/msnnkwlo0050000002msn/direct/01/?href=http://clk.atdmt.com/MSN/go/msnnkwlo0050000001msn/direct/01/?href=http://www.windowsonecare.com/?sc_cid=msn_hotmail


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to