3

I'm using HtmlAgilityPack as part of an automated process to extract content from existing internal web pages. The problem is that I need to be able to make it think IsPostBack is true.

This is the flow:

  • Make initial call to page and extract HTML.

  • Parse HTML to extract __EVENTVALIDATION, __VIEWSTATE, __EVENTTARGET etc... and append them to my next POST back to the same page.

  • Append specific criteria to POST to simulate user input (date range selection for instance).

  • POST back to same page and retrieve HTML from response.

It works in testing, two of the criteria are set based on my submission. But two more are overridden inside an IsPostBack check. So far I have not been able to get it to see IsPostBack as being true on the second request.

Does anyone know specifically what ASP.NET looks at to set IsPostBack?

John Saunders
  • 160,644
  • 26
  • 247
  • 397
Underground
  • 127
  • 5
  • I have edited your title. Please see, "[Should questions include “tags” in their titles?](http://meta.stackexchange.com/questions/19190/)", where the consensus is "no, they should not". – John Saunders Aug 18 '14 at 14:40
  • I don't know the answer, but if it's not one of the ones you're doing, I'd recommend using Fiddler to watch an actual post, and compare that to your fake post, to see if you can track down the difference. Might as well make your fake post as close to reality as possible. – Joe Enos Aug 18 '14 at 15:02
  • Yeah, I even wrote some code to automatically duplicate the headers, but I still get the same behavior. – Underground Aug 18 '14 at 15:10
  • Didn't get this to work, but I did figure out a workaround. It involves setting different parameters, but I have to make a separate call for each one. Retrieve the updated VIEWSTATE, then use that in the next call and set the next parameter. It's a PITA but it does achieve what I need with this specific instance. – Underground Aug 18 '14 at 19:19
  • Ouch, what a hassle. This is one of many reasons I do everything possible to avoid WebForms at all costs. It's a nightmare to do anything even slightly out of the ordinary. – Joe Enos Aug 20 '14 at 15:13
  • why not re-posting the form by inserting/finding an and clicking it using javascript when the page is fetched, going after _EVENTTARGET _EVENTARGUMENT and the others hidden input require an inner understanding of how asp.net framework works – Tawfik Khalifeh Sep 09 '14 at 13:31

1 Answers1

0

for spoofing you need to simple page like that which you want spoof that page

for simple page you want than you need to download this software for copy offline browser for this software you will get HTML,CSS,JS.

than you can use it

http://www.httrack.com/