简体   繁体   English

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

[英]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=m‌​ethodname . 如果要调用自定义服务器端程序集,则必须在查询字符串中提供DLL名称和方法名称,如下所示: http://localhost/installname/eware.dll?SID=xxxxx&Act=123&dotnetdll=dllname&dotnetfunc=m‌​ethodname 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.

相关问题 从asp.net端向Tally服务器发送Http请求 - Http Request to Tally server from asp.net side 如何使用JS参数传递ASP.NET服务器端标记 - How to pass ASP.NET server side tags with JS parameters ASP.NET双列表框使用JQuery更新了客户端,以及如何在服务器端检索结果 - ASP.NET dual listboxes updated client-side with JQuery, and how to retrieve the results server-side 服务器端的HTTP POST请求进度 - HTTP POST request progress on server side Datatable.net-服务器端处理参数 - Datatable.net - server side processing parameters 启动后但上载请求有效负载之前,如何拦截(服务器端)非流HTTP WCF请求 - How to intercept (server side) a non-streaming HTTP WCF request after it is started but before the request payload is uploaded 使用一些参数编写HTTP请求并检索XML响应 - Write HTTP request with some parameters and retrieve XML response 无法从HTTP Post检索服务器端的消息正文 - Unable to retrieve message body on server-side from HTTP Post 如何从 ASP.NET Web API ValueProvider 中的 HTTP POST 请求检索正文值? - How do I retrieve body values from an HTTP POST request in an ASP.NET Web API ValueProvider? 如何从 webApi 上的 http 请求中检索 CancellationToken? - How to retrieve CancellationToken from http request on webApi?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM