simple form question

G

Guest

I have a simple form question. I order to access a payment gateway I have a
asp.net page which has to have a form that use POST for method and _blank for
target. Before the information of the form can be send of, a checksum has to
be calculated. I want to calculate the checksum server side for security
reasons. The way I do it the checksum is not calculated before the form I
posted. The following is simplified content of the aspx .


<html>
<header>
<%@ Import Namespace=â€System.Security.Cryptography “ %>
<script language=â€C#†runat=â€serverâ€>

void Page_Load(Object sender, EventArgs e) {
PageDataBind();
}

string makeMD5( string s) {
return MD5(s); // The code here is VERY simplified
}

</script>
</header>
<body>
<form id=https://secure.paymentgateway.com/window.php method=â€postâ€
target=â€_blankâ€>
<input type=â€hidden†name=â€checksumMD5†value=<%# makeMD5( makeMD5(
amount.Value.ToString() ); %> />

<input type=â€text†id=â€amount†runat=â€server†/>

<input type=â€submit†value=â€submit>

</form>
</body>
<html>


I have also tried to let form=â€server†and that way calculate in a cs file
server side. I just could’t if any function I C# waould let me form posting
to the payment gateway page.

Any suggestions?

Thanks in advance for any help,
 
K

Kevin Spencer

Hi adam,

You have a couple of problems here. First, if you use a WebForm, you can't
post to a remote server; a WebForm posts only to itself. Second, if you add
a form or put a form outside of a WebForm, you cannot add Controls to it.

From what I can see, you have 2 alternatives:

1. Use a WebForm in the page, and add a second form to the page dynamically,
by adding literal HTML to the page, and filling in the dynamicparts via
Response.Write to the page inside the HTML form. It cannot have any
WebControls in it, but you don't need WebControls to do a POST.
2. Do your POST on the server-side using a WebClient. Grab the contents from
the Response, and put them into a page that is popped up by the WebForm via
JavaScript, when it returns to the client.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
You can lead a fish to a bicycle,
but you can't make it stink.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top