Tag Archives: Actionscript

Post Data from SWF to ASPX file

Hi all,

Few days back I was working on an application where i needed to post shopping cart data from swf to aspx page.

Sample codes are available over the internet to post data from swf but you never get “ready to use code”  all the time.

I was trying to post data in XML format and there was a catch in case of aspx files that i did not notice.

I was getting “HTTP Error 500 Internal server error” every time my swf posted data to aspx file. After some research I got the reason.

I missed ValidateRequest=”false” on the Page directive of the aspx page i was trying to POST data to, finally i succeeded 🙂

Here is an excerpt from my code

public function sendOrder(items:String):Void

{

var reply_lv = new LoadVars();

reply_lv.replyTo =””;

var send_lv = new LoadVars();

send_lv.xmlData = items;

send_lv.sendAndLoad(“http://www.yourdomain.com/yourpage/Checkout.aspx”, reply_lv, “POST”);

reply_lv.onLoad = function(Sucess){

if(Sucess)

{

getURL(reply_lv.replyTo);

}

else

{

Alert.show(“Sorry! Failed to send your order this time. Please try again.”);

}

}

}