我正在使用ASP.NET 4.0,C#,Web窗體和母版頁。Authorize.Net靜默發佈問題
我試圖實施Authorize.Net的無聲郵功能,並創建了幾個測試頁
我有一個測試頁面(Silent_Test)與按鈕的帖子轉到其他頁面(靜音)。問題似乎是,無聲頁面只會在加載無聲頁面(即,將Silent_Test用戶重定向到無聲頁面加載頁面上的單擊按鈕)時通過POST捕獲信息。這是有道理的,因爲信息在頁面加載事件中,但我知道Authorize.Net的Silent Post不會加載頁面,所以如果頁面從未加載過,我如何捕獲它們的POST信息?是我的理解,還是我以錯誤的方式去做?......任何人都可以提供提示或示例代碼來捕獲/處理信息Authorize.Net發送在靜默郵政?
Silent_Test.ASPX
<%@ Page Title="Silent Test" Language="C#" MasterPageFile="~/MasterPages
/Site.master" AutoEventWireup="true"
CodeFile="Silent_Test.aspx.cs" Inherits="_Silent_Test" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="Server">
<form action="https://www.test.com/silent.aspx" method="post">
<input type="hidden" name="x_response_code" value="9"/>
<input type="hidden" name="x_cust_id" value="99999999-9999-9999-9999-999999999999"/>
<input type="submit"/>
</form>
</asp:Content>
Silent_Test.ASPX.CS - 代碼沒有被修改 -
Silent.ASPX
<%@ Page Title="Silent" Language="C#" MasterPageFile="~/MasterPages/Site.master"
AutoEventWireup="true" CodeFile="Silent.aspx.cs" Inherits="_Silent" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="Server"></asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="Server">
<div>
<%-- There is no need to put anything in the .ASPX file since Authorize.net's server does not care about the response from the POST call.--%>
<p>You have reached this page in error. Please verify you have the correct web page address.</p>
</div>
</asp:Content>
Silent.ASPX.CS
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data.SqlClient;
public partial class _Silent : BasePage
{
protected void Page_Load(object sender, EventArgs e)
{
string connectionString = ConfigurationManager.ConnectionStrings["ASPNETDBConnectionString1"].ConnectionString;
string insertSql = "INSERT INTO Silent(x_cust_id, x_response_code)
VALUES(@cust_id,@response_code)";
using (SqlConnection myConnection = new SqlConnection(connectionString))
{
myConnection.Open();
SqlCommand myCommand = new SqlCommand(insertSql, myConnection);
myCommand.Parameters.AddWithValue("@cust_id", this.Request.Form["x_cust_id"]);
myCommand.Parameters.AddWithValue("@response_code",
this.Request.Form["x_response_code"]);
myCommand.ExecuteNonQuery();
myConnection.Close();
}
}
}
得到404錯誤爲這些網址 – Kiquenet