[英]How to retrieve Http Request parameters on .NET server side
I have made a call to a .NET DLL (class library project) using XmlHttpRequest: 我已经使用XmlHttpRequest调用了.NET DLL(类库项目):
function httpGet(theUrl, sendParam) {
var xmlHttp = null;
xmlHttp = new XMLHttpRequest();
xmlHttp.open('POST', theUrl, false);
xmlHttp.setRequestHeader('Content-Type', 'text/xml');
xmlHttp.send(sendParam);
var strHtml = xmlHttp.responseText;
xmlHttp = null; // always clear the XmlHttp object when you are done to avoid memory leaks
return strHtml;
}
How could I retrieve the parameters at server side that are sent using .send() method of the above request? 我如何在服务器端检索使用上述请求的.send()方法发送的参数?
Additional Information: 附加信息:
Basically in the Sage CRM it calls a DLL (eware.dll) in the browser to render output for Sage CRM pages. 基本上在Sage CRM中,它在浏览器中调用DLL(eware.dll)来呈现Sage CRM页面的输出。 And if we want to call our custom server side assembly we have to provide DLL name and method name in query string like this: http://localhost/installname/eware.dll?SID=xxxxx&Act=123&dotnetdll=dllname&dotnetfunc=methodname
. 如果要调用自定义服务器端程序集,则必须在查询字符串中提供DLL名称和方法名称,如下所示: http://localhost/installname/eware.dll?SID=xxxxx&Act=123&dotnetdll=dllname&dotnetfunc=methodname
。 So the question is in this scenario. 所以问题就在这种情况下。
Later I found the way to retrieve the querystring parameter on the server side (library project/DLL) using Sage CRM .NET API, however still wandering if we could have been able to retrieve the xmlHttpRequest.send() parameters in the server side library porject (DLL)? 后来,我找到了使用Sage CRM .NET API在服务器端(库项目/ DLL)中检索querystring参数的方法,但是如果我们能够在服务器端库中检索xmlHttpRequest.send()参数,仍在徘徊注入(DLL)?
I made the what you want in the following way: 我通过以下方式制作了想要的东西:
var request = new XMLHttpRequest();
request.responseType = "blob";
request.open("GET", '/Reports/Report1?type=myParam');
request.onload = function () {
var url = window.URL.createObjectURL(this.response);
var a = document.createElement("a");
document.body.appendChild(a);
a.href = url;
a.download = this.response.name || "Mensajes" + $.now()
a.click();
}
request.send();
$scope.procesando = true;
$scope.procesando = false;
And in the server side: 在服务器端:
[HttpGet]
public FileStreamResult Report1()
{
string tipo = Request.QueryString["type"];
...
...
...
}
Hope it helps you. 希望对您有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.