我將查詢字串傳遞給我的 ASP.NET Core MVC Web 模擬器:
window.location.href = "https://localhost:7064/PaymentGateWayBillDesk/HitPaymentGateWay?queryString=" data;
單擊按鈕時如何讀取查詢字串?
public virtual async Task<IActionResult> HitPaymentGateWay(string queryString)
{
String[] token = queryString.Split('|');
if (token.Length == 22)
{
merchantId = token[0].ToString();
subscriberid = token[1].ToString();
txnReferenceNo = token[2].ToString();
bankReferenceNo = token[3].ToString();
txnAmount = token[4].ToString();
totalTxnAmount = txnAmount;
bankId = token[5].ToString();
bankMerchantId = token[6].ToString();
itemCode = token[9].ToString();
txnDate = token[13].ToString();
authStatus = token[14].ToString();
authStatusId = 1;
settlementType = token[15].ToString();
RU = token[21].ToString();
}
var vm = new PaymentDetailsModel()
{
ReturnUrl = RU
};
return View(vm);
}
uj5u.com熱心網友回復:
嘗試:
window.location.href = "https://localhost:7064/PaymentGateWayBillDesk/HitPaymentGateWay?queryString= data";
或者:
window.location.href = "https://localhost:7064/PaymentGateWayBillDesk/HitPaymentGateWay?queryString=" "data";
結果:

一個demo你可以參考:
索引視圖:
<button onclick="go2()">window.location.href</button>
<script>
//function go2() { window.location.href = "https://localhost:7237/Home/HitPaymentGateWay?queryString= data"; }
function go2() { window.location.href = "https://localhost:7237/Home/HitPaymentGateWay?queryString=" "data"; }
</script>
結果:

轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/521607.html
