0

I'm working from some sample code, provided in PHP - we are using c#, so i'm having to convert it. Basically, it requires that i submit a bunch of data to an API, which returns an xml document as a response.

I then need to redirect to a page, that has the following HTML:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Redirect Test Page</title>
</head>
<body OnLoad="OnLoadEvent();" >

<form name="downloadForm" action="ACS_URL_GOES_HERE" method="POST">
    <input type="hidden" name="PaReq" value="PAREQ_GOES_HERE">
    <input type="hidden" name="TermUrl" value="TERM_URL_GOES_HERE">
    <input type="hidden" name="MD" value="MD_GOES_HERE">
<noscript>
    <center>
        <h1>Processing your 3-D Secure Transaction</h1>
        <h2>JavaScript is currently disabled or is not supported by your browser.</h2><br>
        <h3>Please click on the Submit button to continue the processing of your 3-D secure transaction.</h3>
        <input type="submit" value="Submit">
    </center>
</noscript>
</form>
<script language="Javascript" >
<!--    
function OnLoadEvent(){
    document.downloadForm.target = "myIframe";
    document.downloadForm.submit();
}
//-->
</script>
<hr>
<iframe src="blank.htm" name="myIframe" width="390" height="450" frameborder="0">
</iframe>
<hr>

</body>
</html>

(the Uppercase variables (ending in _GOES_HERE) above are going to be passed in from the response XML document)

This page, once loaded, submits, and puts the result in the iFrame - called "myIframe"

That's basically it!

I'm having great trouble doing something like this in C# - in PHP: they have this:

function RedirectToACSPage ($doc, $data_set) {
// error_log ("Call RedirectToACSPage");
// error_log ($doc->get("Response.CardTxn.ThreeDSecure.pareq_message"));
$pareq = $doc->get("Response.CardTxn.ThreeDSecure.pareq_message");
$acs_url = $doc->get("Response.CardTxn.ThreeDSecure.acs_url");
// $acs_url = "http://staging.datacash.com/ops/cgi/args.php";

// error_log ("PAREQ: " . $pareq);
// error_log ("ACS URL: " . $acs_url);
$term_url = "https://staging.datacash.com/ops/tester/next.php";
$md = $doc->get("Response.datacash_reference") . ":" . $data_set{'vtid'} . ":" .     $data_set{'password'} . ":" . $data_set{'tran_type'} . ":" . $data_set{'url'}

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Redirect Test Page</title>
</head>
<body OnLoad="OnLoadEvent();" >

<form name="downloadForm" action="<?php echo $acs_url ?>" method="POST">
    <input type="hidden" name="PaReq" value="<?php echo $pareq ?>">
    <input type="hidden" name="TermUrl" value="<?php echo $term_url ?>">
    <input type="hidden" name="MD" value="<?php echo $md ?>">
<noscript>
    <center>
        <h1>Processing your 3-D Secure Transaction</h1>
        <h2>JavaScript is currently disabled or is not supported by your browser.    </h2><br>
    <h3>Please click on the Submit button to continue the processing of your 3-D secure transaction.</h3>
    <input type="submit" value="Submit">
</center>
</noscript>
</form>
<script language="Javascript" >
<!--    
function OnLoadEvent(){
    document.downloadForm.target = "joe";
    document.downloadForm.submit();
}
//-->
</script>


1
  • Are you using webforms and is the iframe redirecting to a page that is part of your application? Commented Sep 1, 2009 at 16:53

1 Answer 1

1

Wow the way you are doing this may make sense in PHP but it is as far as you can get from webforms assuming that is what you are using.

If you are familiar with PHP I'd recommend using ASP.Net MVC over webforms but from the sound of what you are saying you've already started down the road of webforms.

The simplest way of taking what you have there and turning it into something that will work is first to start using jQuery because it will save you time with javascript, then remove the OnLoadEvent function from your aspx and use the script manager to register it in your code behind. In your javascript function you can then change the value of the hidden fields before submitting.

Although having said that, you are better off redesigning the page to work better with asp.net webforms. You could have the entire flow done on one page if necessary, using updatepanels or postbacks to update the screen. I'd recommend having a look at sample asp.net code and seeing how flow is handled because it's very different and will take a bit of getting used to.

Sign up to request clarification or add additional context in comments.

2 Comments

i can't use asp.net MVC, have to plug it into existing application. and, as i said, there is no sample asp.net code for this application
No I mean that you need to look at c# code written by a c# coder, any code, just to learn the way it is written. Not enough to know what it can do or the syntax, also need to learn the style. WebForms are written very similarly to a WinForms (Windows application). They handle events more so than page requests.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.