Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/279.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/30.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# ASP.net请求发布的表单数据始终为空_C#_Asp.net_Forms_Null - Fatal编程技术网

C# ASP.net请求发布的表单数据始终为空

C# ASP.net请求发布的表单数据始终为空,c#,asp.net,forms,null,C#,Asp.net,Forms,Null,以下是Javascipt: $.ajax({ type: "POST", data: "langID=" + viewingLangID + "&currency=" + newVal + "&basePrices=" + pricePostData, dataType: "json", url: "/handlers/payments/getconversions.ashx", success: function(data) { 生成以

以下是Javascipt:

$.ajax({
    type: "POST",
    data: "langID=" + viewingLangID + "&currency=" + newVal + "&basePrices=" + pricePostData,
    dataType: "json",
    url: "/handlers/payments/getconversions.ashx",
    success: function(data) {
生成以下HTTP请求:

General
Request URL:https://127.0.0.1:3333/handlers/payments/getconversions.ashx
Request Method:POST
Status Code:200 OK
Remote Address:127.0.0.1:3333

Response Headers
Cache-Control:private
Content-Length:78
Content-Type:application/json; charset=utf-8
Date:Mon, 01 Feb 2016 17:35:41 GMT
Server:Microsoft-IIS/8.5
X-AspNet-Version:4.0.30319
X-MiniProfiler-Ids:["9d45ff72-2efa-4d31-a5c7-c109573699c6"]
X-Powered-By:ASP.NET

Request Headers
Accept:application/json, text/javascript, */*; q=0.01
Accept-Encoding:gzip, deflate
Accept-Language:en-GB,en-US;q=0.8,en;q=0.6
Connection:keep-alive
Content-Category:application/x-www-form-urlencoded; charset=UTF-8
Content-Length:62
Content-Type:text/plain;charset=UTF-8
Cookie:C3_Login=ID=e99af6ee-b0fc-4d92-89f6-262d37d7a2b0&Key=BAFKzQhxZsknMyE1bvbjsFouDvaZUSxVzP0oGmN8kONCJRUR1z; _gat=1; _ga=GA1.1.1302222369.1453808296; C3_Currency=GBP
Host:127.0.0.1:3333
Origin:https://127.0.0.1:3333
Referer:https://127.0.0.1:3333/?p=ContentIndividuals
User-Agent:Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.111 Safari/537.36
X-Requested-With:XMLHttpRequest

Request Payload
langID=2&currency=GBP&basePrices=299,799,2499,9999,10999,13999
但是,在
getconversions.ashx
上,如果我这样做:

context.Request.Form["currency"]
该值始终为
null
。知道为什么会这样吗?我尝试了Request[“currency”]和
Request.Params[“currency”]
,但它总是返回
null

如果我记录context.Request.ServerVariables[“ALL_RAW”]

Connection: keep-alive
Content-Length: 62
Content-Type: text/plain;charset=UTF-8
Accept: application/json, text/javascript, */*; q=0.01
Accept-Encoding: gzip, deflate
Accept-Language: en-GB,en-US;q=0.8,en;q=0.6
Cookie: C3_Login=ID=e99af6ee-b0fc-4d92-89f6-262d37d7a2b0&Key=BAFKzQhxZsknMyE1bvbjsFouDvaZUSxVzP0oGmN8kONCJRUR1z; _gat=1; _ga=GA1.1.1302222369.1453808296; C3_Currency=GBP
Host: 127.0.0.1:3333
Referer: https://127.0.0.1:3333/?p=ContentIndividuals
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.111 Safari/537.36
Content-Category: application/x-www-form-urlencoded; charset=UTF-8
Origin: https://127.0.0.1:3333
X-Requested-With: XMLHttpRequest

尝试将数据转换为对象。目前数据不是json格式

var jsonData = {'langID':viewingLangID, 'currency':newVal, 'basePrices':pricePostData}

$.ajax({
    type: "POST",
    data: jsonData,
    dataType: "json",
    url: "/handlers/payments/getconversions.ashx",
    success: function(data) {
还要注意,
pricePostData
的值应该是json
[123234456567]
等的数组


希望这有帮助

其他价值观呢?它们也是空的吗?@Shaharyar是的,都是空的。请求URL引用程序返回正确的值,但显然无法获得任何已发布的值!我不确定它是否能解决您的问题,请尝试使用对象作为数据参数:data:{langID:viewingLangID,currency:newVal…}您缺少
contentType:“application/x-www-form-urlencode”
。设置它并再次检查。我可以看到响应头将其作为JSON(
application/JSON
)接收,但实际上它不是JSON对象。@Shaharyar设置仍然发送
内容类型:text/plain;字符集=UTF-8