views:

953

answers:

3

Hi,

I am trying to integrate 3D Secure to my customer's e-shop. I need to post some data to 3DGate and get the returned result from it.

I have used WebRequest for this, i have posted the data successfuly but the returned data is an Html Text which has a form in it and some inputs in the form. I need to read these values like Request.Form.Get("HashParams") but because of being just a string i couldn't do it.

Is there any way that i can get these form values.

*I am doing this WebRequest in the btnPayment_Click Event*

Thanks

+1  A: 

I believe madcolor is thinking of a different scenario; you're making a completely new webrequest on the server, which means there are no request parameters; you're dealing with a response. Esentially, you've become the web browser, and you have to do the parsing yourself.

Since the e-store you're using is an app that's designed for browsers, you'll have to deal with the limitations inherent to that format. You're esentially bound to "screen scraping" techniques, because the server doesn't see the text from the response as anything other than that: plain text.

If you're dealing with valid XHTML, you can load it into an XmlDocument, and use XPath/XQuery to pull out the values.

If you're dealing with standard crappy HTML, you're going to have to resort to some parsing; I'd suggest a regex for this one.

Ideally, there would be a non-HTML based version of the e-shop, so you would know you were working with valid XML/JSON/whatever, but if there is no alternative, you're stuck ripping the data out yourself.

jvenema
I ve posted the xhtml, could you please take a look
Barbaros Alp
A: 

I can't see a way around having to parse the HTML that comes back from the WebRequest. If you're lucky it might be valid XML. Otherwise you'll have to do your own string parsing or use one of the other HTML parsers.

David
A: 

This is the returned data...

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<!-- gateerr_en.htm -->
<html>
<head>
<script type="text/javascript" language="javascript">
function moveWindow() {
  document.returnform.submit();
}
</script>  
</head>

<body onLoad="javascript:moveWindow()">
<form action="urlHere" method="post" name="returnform">

    <input type="hidden" name="clientid" value="xxx">
    <input type="hidden" name="oid" value="">

    <input type="hidden" name="mdStatus" value="7">
    <input type="hidden" name="mdErrorMsg" value="Tanimlanamayan">

    <input type="hidden" name="ErrMsg" value="Tanimlanamayan">
    <input type="hidden" name="Response" value="Error">
    <input type="hidden" name="ProcReturnCode" value="99"> 


    <!-- To support javascript unaware/disabled browsers -->
    <noscript>
     <center>
     An Error Occurred, Please Click to continue.<br>
     <input type="submit"  value="Submit"></center>
    </noscript> 
</form>
</body>
</html>

I need to get those hidden inputs

Barbaros Alp
Use this regex:<input type="hidden".+value="(.*)"/{0,1}>That'll give you only the inputs with type hidden, and the first group will have the value.
jvenema