Showing results for 
Search instead for 
Did you mean: 

Accept Hosted Form CSS & JS 404 errors



I trying to integrate to Accept hosted feature, but now I'm getting 404 errors when render the form in an iframe.


The resources for the hosted form are relative paths and seems to be linking to my local address, and get 404 errors for each css and js file referenced.


My code is in ASP.NET and I'm using the Authorize.Net SDK.


Here is my code:



public class GetAnAcceptPaymentPage
		public static ANetApiResponse Run(String ApiLoginID, String ApiTransactionKey, decimal amount)
			Console.WriteLine("GetAnAcceptPaymentPage Sample");
			ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = AuthorizeNet.Environment.SANDBOX;
			ApiOperationBase<ANetApiRequest, ANetApiResponse>.MerchantAuthentication = new merchantAuthenticationType()
				name = ApiLoginID,
				ItemElementName = ItemChoiceType.transactionKey,
				Item = ApiTransactionKey,

			settingType[] settings = new settingType[2];

			settings[0] = new settingType();
			settings[0].settingName = settingNameEnum.hostedPaymentButtonOptions.ToString();
			settings[0].settingValue = "{\"text\": \"Pay\"}";

			settings[1] = new settingType();
			settings[1].settingName = settingNameEnum.hostedPaymentOrderOptions.ToString();
			settings[1].settingValue = "{\"show\": false}";

			var transactionRequest = new transactionRequestType
				transactionType = transactionTypeEnum.authCaptureTransaction.ToString(),    // authorize capture only
				amount = amount

			var request = new getHostedPaymentPageRequest();
			request.transactionRequest = transactionRequest;
			request.hostedPaymentSettings = settings;

			// instantiate the contoller that will call the service
			var controller = new getHostedPaymentPageController(request);

			// get the response from the service (errors contained if any)
			var response = controller.GetApiResponse();

			if (response != null && response.messages.resultCode == messageTypeEnum.Ok)
				Console.WriteLine("Message code : " + response.messages.message[0].code);
				Console.WriteLine("Message text : " + response.messages.message[0].text);
				Console.WriteLine("Token : " + response.token);
			else if (response != null)
				Console.WriteLine("Error: " + response.messages.message[0].code + "  " + response.messages.message[0].text);
				Console.WriteLine("Failed to get hosted payment page");

			return response;

public class HomeController : Controller

        ANetApiResponse response;

        public ActionResult Index()
            return View();

        public ActionResult ShowForm()
			response = GetAnAcceptPaymentPage.Run("<API_ID>", "<TransactionKey>", 499);
			Dictionary<string, string> dict = new Dictionary<string, string>();
            dict.Add("token", ((getHostedPaymentPageResponse)response).token);

            string form = HttpPostRequest("", dict);

            return Content(form);

		private string HttpPostRequest(string url, Dictionary<string, string> postParameters)
			string postData = "";

			foreach (string key in postParameters.Keys)
				postData += HttpUtility.UrlEncode(key) + "="
					  + HttpUtility.UrlEncode(postParameters[key]) + "&";

			HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(url);
			myHttpWebRequest.Method = "POST";

			byte[] data = Encoding.ASCII.GetBytes(postData);

			myHttpWebRequest.ContentType = "application/x-www-form-urlencoded";
			myHttpWebRequest.ContentLength = data.Length;

			Stream requestStream = myHttpWebRequest.GetRequestStream();
			requestStream.Write(data, 0, data.Length);

			HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();

			Stream responseStream = myHttpWebResponse.GetResponseStream();

			StreamReader myStreamReader = new StreamReader(responseStream, Encoding.Default);

			string pageContent = myStreamReader.ReadToEnd();



			return pageContent;



<iframe src='@Url.Action("ShowForm", "Home")'  width="100%" height="400"></iframe>



Hi @yunier0525,


It looks like you're posting the token from your server, getting the form returned to your server, and then turning around and feeding the form to the client. Unfortunately, that's not going to work.


The key to the hosted form is that the customer's browser loads the form directly from our server, and submits their input directly back to our server. So, after you get the token, you don't submit the token to us. You write a response back to the customer's browser that contains the token in an HTML form, and cause the customer's browser to submit that form to our server.

All Star