WCF服务,使用的参数下载文件时,发送的GET请求数据 [英] WCF Service, Download file with parameters, send data on GET request

查看:138
本文介绍了WCF服务,使用的参数下载文件时,发送的GET请求数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

jQuery有用于与 GET 请求发送数据的支持:

jQuery has support for sending data with a GET request:

jQuery.get( url [, data ] [, success(data, textStatus, jqXHR) ] [, dataType ] )

是否有可能编写支持接收数据上的 GET 要求?WCF服务

这是例子太多AP preciated。

An example is much appreciated.

更新:URL长度超过了限额IE8和IE8是一个要求。我需要通过大量的参数,基本上是一个大的JSON。我所做的,以解决此就是让 POST 要求,参数存储在服务器端,然后设置 window.location的的服务位置调用 GET 的要求,将下载我的file.But,我想避免的 POST 要求,并存储在服务器端的文件,因为我是在分布式系统中,我有很多的问题与此有关。

UPDATE: Url length exceeds the limit for IE8 and IE8 is a requirement. I need to pass a lot of parameters, basically a big JSON. What I did to workaround this is to make a POST request,store the parameters on the server side, then set window.location to the service location the invoke a GET request that will download my file.But, I want to avoid the POST request and storing the file on server side because I'm in a distributed system and I have a lot of issues with this.

推荐答案

当然,您可以:

[OperationContract]
[WebInvoke(
    Method = "GET",
    UriTemplate = "SomeUrl?param1={param1}&param2={param2}"
)]
string SomeOperation(string param1, string param2);

然后:

$.get('SomeService.svc/SomeUrl?param1=SomeValue&param2=AnotherValue', function(response) {
    console.log(response);
});

或者

$.get('SomeService.svc/SomeUrl', {param1: 'SomeValue', param2: 'AnotherValue'}, function(response) {
    console.log(response);
});

这篇关于WCF服务,使用的参数下载文件时,发送的GET请求数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆