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

标签 c# javascript .net dll 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;
}

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

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

后来我找到了使用 Sage CRM .NET API 在服务器端(库项目/DLL)检索查询字符串参数的方法,但是仍然徘徊是否我们能够检索 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"];
    ...
    ...
    ...
}

希望对您有帮助。

关于c# - 如何在.NET服务器端检索Http请求参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24728633/

相关文章:

c# - 如何在 C# 中使用 jquery ajax?

C# 为什么我的控件不接受 KeyDown 事件中的多个键

c# - 多个包与指定模式匹配 : %s. 请限制搜索模式

javascript - Google Analytics - 增强的链接归因

c# - 在代码中设置开关

c# - 比较通用接口(interface)类型

javascript - 如果其他元素不显示,则填充剩余空间

javascript - 有没有 javascript ssh 客户端?

c# - 如何覆盖 WcF 对象的 ToString 方法?

c# - 异常 : Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host