我在ASP.NET Core 2.0中创建一个应用程序,我需要创建一个希腊银行提供的Checkout端点。 (阿尔法银行) 他们在ASP.NET Web Forms应用程序中提供了必要的实现,我必须将必需的信息发布到他们的端点。 问题是我在我的ASP.NET核心应用程序中重新创建了与POST完全相同的形式,我无法让它工作。
ASP.NET Web窗体实现(正常工作)
表格
<form method="post" id='form_digest' runat="server" >
<div>
<asp:Label ID="Label1" runat="server" Height="45px" Style="font-weight: bold; font-size: 30px;
border-top-style: none; border-right-style: none; border-left-style: none; border-bottom-style: none"
Text="Alpha Test Shop" Width="306px"></asp:Label><br />
<br />
<table>
<tr>
<td style="width: 198px">
MerchantID</td>
<td style="width: 330px">
<asp:TextBox ID="mid" runat="server" Width="124px">123</asp:TextBox></td>
</tr>
<tr>
<td style="width: 198px">
Order ID</td>
<td style="width: 330px">
<asp:TextBox ID="orderid" runat="server" Width="138px">123</asp:TextBox></td>
</tr>
<tr>
<td style="width: 198px">
Order Desc</td>
<td style="width: 330px">
<asp:TextBox ID="orderDesc" runat="server" Width="153px">OrderDesc</asp:TextBox></td>
</tr>
<tr>
<td style="width: 198px">
Ποσό</td>
<td style="width: 330px">
<asp:TextBox ID="orderAmount" runat="server" Width="129px">0,2</asp:TextBox></td>
</tr>
<tr>
<td style="width: 198px">
Νόμισμα</td>
<td style="width: 330px">
<asp:DropDownList ID="currency" runat="server">
<asp:ListItem>EUR</asp:ListItem>
</asp:DropDownList></td>
</tr>
<tr>
<td style="width: 198px">
Τρόπος Πληρωμής</td>
<td style="width: 330px">
<asp:DropDownList ID="payMethod" runat="server">
<asp:ListItem Value="">No pre Selection</asp:ListItem>
<asp:ListItem Value="visa">VISA</asp:ListItem>
<asp:ListItem Value="visaElectron">Visa Electron</asp:ListItem>
<asp:ListItem Value="mastercard">MasterCard</asp:ListItem>
<asp:ListItem Value="maestro">Maestro</asp:ListItem>
</asp:DropDownList></td>
</tr>
<tr>
<td style="width: 198px">
Σελίδα Confirmation</td>
<td style="width: 330px">
<asp:TextBox ID="confirmUrl" runat="server" Width="247px">success.aspx</asp:TextBox></td>
</tr>
<tr>
<td style="width: 198px">
Σελίδα
Cancel</td>
<td style="width: 330px">
<asp:TextBox ID="cancelUrl" runat="server" Width="247px">fail.aspx</asp:TextBox></td>
</tr>
<tr>
<td style="width: 198px">
Digest</td>
<td style="width: 330px">
<asp:TextBox ID="digest" runat="server" Width="247px">raJKiCtB1Eupp/YmSKlAlWd+kT0=</asp:TextBox></td>
</tr>
</table>
<br />
<br />
<asp:Button ID="Button2" runat="server" Text="Submit" Width="113px" /><br />
<br />
<br />
</div>
</form>
脚本
function noPostBack()
{
document.forms[0].action = "https://alpha.test.modirum.com/vpos/shophandlermpi";
document.forms[0].__VIEWSTATE.name = 'NOVIEWSTATE';
document.forms[0].submit();
}
ASP.NET核心实施(不工作) 的表格
<form method="post" id='form_digest'>
<div class="col-md-12">
<div class="row margin-top-10">
<input id="mid" name="mid" value="123" class="form-control" />
</div>
<div class="row margin-top-10">
<input id="orderid" name="orderid" value="123" class="form-control" />
</div>
<div class="row margin-top-10">
<input id="orderDesc" name="orderDesc" value="OrderDesc" class="form-control" readonly />
</div>
<div class="row margin-top-10">
<input id="orderAmount" name="orderAmount" value="0,2" class="form-control" readonly />
</div>
<div class="row margin-top-10">
<input id="currency" name="currency" value="EUR" class="form-control" readonly />
</div>
<div class="row margin-top-10">
<input id="payMethod" name="payMethod" value="visa" class="form-control" />
</div>
<div class="row margin-top-10">
<input id="confirmUrl" name="confirmUrl" value="success.aspx" class="form-control" readonly />
</div>
<div class="row margin-top-10">
<input id="cancelurl" name="cancelurl" value="fail.aspx" class="form-control" readonly />
</div>
<div class="row margin-top-10">
<input id="digest" name="digest" value="raJKiCtB1Eupp/YmSKlAlWd+kT0=" class="form-control" />
</div>
</div>
</form>
<div class="row">
<button id="Button1" type="button" class="btn btn-md btn-block u-btn-primary" onclick="noPostBack()"><span class="fa fa-money"></span> @localizer["AcceptAndPay"]</button>
</div>
脚本
function noPostBack() {
document.forms[0].action = "https://alpha.test.modirum.com/vpos/shophandlermpi";
//document.forms[0].__VIEWSTATE.name = 'NOVIEWSTATE';
document.forms[0].submit();
}
问题 如你所见,表格是一样的。它发布在同一端点,但是从ASP.NET Core应用程序中我收到错误
“无效的商家ID:null”
我能看到的唯一区别是在脚本中我找不到它正在做什么,所以它可能与我的错误有关。
document.forms[0].__VIEWSTATE.name = 'NOVIEWSTATE';
另一方面,我想也许我错过了一个配置选项,但我找不到。
我一直在为此苦苦挣扎,所以任何帮助都会受到高度赞赏。
PS :我给出了一个过于简化的示例,其中我将成功网址和取消网址设置为ASP.NET Web Forms示例的相同.aspx页面。这只是为了重新创建从函数创建的完全相同的摘要值,所以不要为此烦恼。
更新 我试图通过Firefox的HTTP Header Live插件看到我的POST请求,我看到我没有发布我的表单值
所以我的问题是为什么会发生这种情况,我该怎么改变?