简体   繁体   中英

Simulate a javascript _dopostback using c#

Is there a way to convert a javascript:_doPostBack to an actual HTTP POST request using c# windows application? I do not want to perform this using an ASP page . I've been trying to figure out it, but have struck out so far. I know that typical doPostBacks handle the eventTarget and eventArgument.

Example:

  <td class="separator">
<a id="myStudentSearch_grdSearchResults__ctl3_lnkStudentName" class="link2" CommandType="Command" href="javascript:__doPostBack('myStudentSearch$grdSearchResults$_ctl3$lnkStudentName','')">Test                   Account                   </a>

javascript:__doPostBack('myStudentSearch$grdSearchResults$_ctl3$lnkStudentName','')

C: httpPost(" http://xsite.com ", "eventTarget=myStudentSearch$grdSearchResults$_ctl3$lnkStudentName&eventArgument=""");

You probably don't want to simulate __doPostBack . What you probably want is to make an HTTP request that looks like it came from some page.

For that, I recommend you to use Fiddler .

Once you know what to send, use HttpClient , WebClient , WebRequest / WebResponse or whatever fits your needs.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM