如何在.net服务器端检索Http请求参数

How to retrieve Http Request parameters on .NET server side

本文关键字:Http 请求 参数 检索 服务器端 net      更新时间:2023-09-26

我已经使用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;
}

我如何在服务器端检索使用上述请求的。send()方法发送的参数?

附加信息:
基本上在Sage CRM中,它调用浏览器中的DLL (eware.dll)来呈现Sage CRM页面的输出。如果我们想调用自定义服务器端程序集,我们必须在查询字符串中提供DLL名称和方法名称,如:http://localhost/installname/eware.dll?SID=xxxxx&Act=123&dotnetdll=dllname&dotnetfunc=m‌​ethodname。所以问题是在这种情况下。

后来我找到了使用Sage CRM .NET API检索服务器端(库项目/DLL)上的querystring参数的方法,但是如果我们能够检索服务器端库项目(DLL)中的xmlHttpRequest.send()参数,我们仍然徘徊?

我用下面的方法制作了你想要的东西:

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;

服务器端:

[HttpGet]
public FileStreamResult Report1()
{
    string tipo = Request.QueryString["type"];
    ...
    ...
    ...
}

希望对你有帮助。