繁体   English   中英

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

[英]How to retrieve Http Request parameters on .NET server side

我已经使用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参数的方法,但是如果我们能够在服务器端库中检索xmlHttpRequest.send()参数,仍在徘徊注入(DLL)?

我通过以下方式制作了想要的东西:

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"];
    ...
    ...
    ...
}

希望对您有帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM