【发布时间】:2017-01-04 10:56:35
【问题描述】:
我有 asp.net mvc 项目,我需要将表单作为 httpRequestObject 发送。 我已经尝试了几天向第 3 方信用卡清算公司 url 发出简单的 XMLhttp 请求,并使用 XML 格式的重定向返回响应 - 我不在乎重定向是由 iframe 还是弹出 检查了整个互联网的解决方案,在 JavaScript 上尝试过——但据我所知,我无法用 JS 来做,也尝试过 asp.net 和 c#,但对我没有任何作用。 检查了这里的所有解决方案,但仍然没有任何效果。 检查我是否被代理或防火墙等任何方式阻止,这不是问题。
我目前的 JS 代码是 -
function createMPITransaction() {
var terminal_id = "0962832";
var merchant_id = "938";
var user = "my-user";
var password = "my-password";
var url="https://cguat2.creditguard.co.il/xpo/Relay";
var xmlStr = "my string";
var http = new XMLHttpRequest();
http.open("POST",url, true);
//Send the proper header information along with the request
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http.setRequestHeader('Access-Control-Allow-Headers', '*');
http.setRequestHeader('withCredentials', true);
http.setRequestHeader('responseType', 'text');
var response = http.responseText;
http.onreadystatechange = function () {//Call a function when the state changes.
if (http.readyState == 4 && http.status == 200) {
alert(http.responseText);
}
}
console.log(xmlStr);
console.log(http);
http.send(xmlStr);
并从控制台获取 -
XMLHttpRequest {readyState: 1, timeout: 0, withCredentials: false, upload: XMLHttpRequestUpload, responseURL: ""…}
我可以在 JS 上做到吗? 如果没有,我怎么能在 asp.net c# 上做到这一点? 请求对 3rd 方服务器的限制,并获得重定向并不常见,这使其成为真正的挑战。
【问题讨论】:
标签: javascript c# asp.net asp.net-mvc redirect