Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

POSTing to ASP.Net page using Apache HttpClient  RSS feed

 
Pawel Kos
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I want to do POST request to ASP.Net page with EventValidation enabled using Apache HttpClient. For example I want to programmicaly accept disclaimer on that page:
http://www.derivate-bnpparibas.de/DE/disclaimer.aspx
But I always get Internal Server Error and I have no idea where is the problem.

Thanks in advance.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

Are you submitting all the form fields (including the hidden one)? You also need to submit the cookie that is set by the page when you first access it.
 
Pawel Kos
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your answer.

Yes, I�m submitting all form fields. I think cookies are handled and subbmited autamatically by the HttpClient if I first make GET request to the page. This is my sample code:

I sholud get redirect to http://www.derivate-bnpparibas.de/DE/index.aspx?pageID=1, but I always get redirect to the error page
[ August 18, 2008: Message edited by: Pawel Kos ]
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's probably a way to make this work, but I'd use jWebUnit instead of HttpClient and an HTML parser. It makes handling HTTP conversations much simpler.

By the way, this is bad:
catch(Exception e) {
}

You should rarely, if ever, catch exceptions and not do anything about them. How would you know if there's a problem?
 
Pawel Kos
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for pointing me to jWebUnit. I didn't know that framework before. This solve my problem.

Cheers
Pawel
 
Eswar Varanasi
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[ UD: Please do not post unrelated questions into existing thread. That's called "hijacking", and is frowned upon. You already started a thread for this question; let's continue the discussion over there.

Please also read the policy on screen names we have here at JavaRanch. I suspect that yours is fictitious, so please take a moment to change it, which you can do right here.]
[ August 28, 2008: Message edited by: Ulf Dittmer ]
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!