We help IT Professionals succeed at work.
Get Started

ASP.net form processing page from Flash

pGustafson asked
Last Modified: 2013-11-11
Is it possible to send form data to a .net page without loading the page? The form data is coming from a flash movie.

If this is possible, what is the best way to do it. I have tried the following code and nothing happens.
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections;
using System.Collections.Specialized;
using System.IO;
using System.Net;
using System.Net.Mail;
using System.Text;
using System.Xml;
using System.Xml.Serialization;
using System.Configuration;

public partial class player_roger_send_form : System.Web.UI.Page
    protected void Page_Load(object sender, EventArgs e)

			string sOrgID, sPostData, sPostToURL, fname, lname, strTitle, strRole, strCompany, strCompanySize, strCountry, strEmail, strPhone, strPhoneExt, campaign, campaignid;

			sOrgID = "xxxx";
			campaign = "xxxxx";
			campaignid = "xxxxxx";
			sPostToURL = "https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8";
			// Fill variables with form data
			fname = Request.Form["First Name"];
			lname = Request.Form["Last Name"];
			strTitle = Request.Form["Title"];
			strRole = Request.Form["Role"];
			strCompany = Request.Form["Company"];
			strCompanySize = Request.Form["Company Size"];
			strCountry = Request.Form["COuntry"];
			strEmail = Request.Form["Email"];
			strPhone = Request.Form["Phone"];
			strPhoneExt = Request.Form["Phone Ext"];

			if (fname != null)

				// Create string to send to SFDC
				sPostData = "&lead_source=Web" +
									 "&00N30000001FBQO=inquiry" +
									 "&00N30000001GFL5=" + campaign +
									 "&Campaign_ID=" + campaignid +
									 "&external=1" +
									 "&oid=" + sOrgID +
									 "&first_name=" + fname +
									 "&last_name=" + lname +
									 "&company=" + strCompany +
									 "&00N30000001FCNQ=" + strCompanySize +
									 "&00N30000001Gqqe=" + strRole +
									 "&title=" + strTitle +
									 "&00N30000001FpGY=" + strCountry +
									 "&email=" + strEmail +
									 "&00N60000001g2Z6= Filled out form after watching videos by xxxxx" +
									 "&phone=" + strPhone + "Ext:" + strPhoneExt +

				// Send Data to SFDC
				sPostToURL = sPostToURL + sPostData;
				String myWebReturn = MakeWebRequest(sPostToURL, "");


		protected string MakeWebRequest(string url, String webProxyServer)
			string returnData = String.Empty;

			WebRequest request = WebRequest.Create(url);
			if (webProxyServer.Trim().Length > 0)
				request.Proxy = GetWebProxy(webProxyServer);
			HttpWebResponse response = (HttpWebResponse)request.GetResponse();

			if (response.StatusCode == System.Net.HttpStatusCode.OK)
				Stream data = response.GetResponseStream();
				StreamReader reader = new StreamReader(data);
				returnData = reader.ReadToEnd();
				Console.WriteLine("Error making WebRequest for url: " + url);

			return returnData;

		protected IWebProxy GetWebProxy(String webProxyServer)
			string webProxyAddress = null;
				webProxyAddress = webProxyServer;
				if (webProxyAddress != null)
					webProxyAddress = webProxyAddress.Trim();
					if (webProxyAddress == String.Empty)
						webProxyAddress = null;
			catch (Exception)
				// Any exception ==> no proxy: the COM interop often throw an exception for the case of no proxy server!
				webProxyAddress = null;

			//Initialize to no proxy
			//IWebProxy iwebProxy = GlobalProxySelection.GetEmptyWebProxy();
			IWebProxy webProxy = WebRequest.DefaultWebProxy;

			if (webProxyAddress != null)
				webProxy = new WebProxy(webProxyAddress);

			return webProxy;

Open in new window

Watch Question
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE