我有asp.net mvc项目,需要以httpRequestObject形式发送。 我想了几天已经向第三方信用卡清算公司的网址做简单的XMLhttp请求,并取回XML格式的重定向响应 - 我不在乎是否通过iframe或弹出 所做的重定向全部检查互联网的解决方案,试用它的JavaScript - 但据我了解,我不能用JS来做到这一点,尝试过asp.net和c#也没有效果。 检查所有的解决方案,但仍然没有工作。 检查我是否以代理或防火墙的方式被阻止,这不是问题。向第三方服务器发送http请求并获得重定向响应
我当前的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#上做到这一点? 对第三方服务器的请求限制,并获得重定向并不常见,使其成为真正的挑战。
感谢 我看到GitHub的实现与Node.js的, 这样我就可以与其他JS库做呢? –
那么...你也用c#标记了你的问题,并要求提供一个c#解决方案。 browserify node.js模块有很多不同的方法可以将它与c#集成在一起:参见这个[example](http://juristr.com/blog/2014/03/integrating-node-with-csharp/).. 。顺带一提我的回答很有帮助;-) ... –