精通ASP.NET WEBAPI的请进
客户端分别用Ajax发送一个Get和Post请求,Get请求后台能收到并执行,我照此写了一个POST的后台方法却不能执行.代码如下
public class Default3Controller : ApiController
{
// GET 后台可以正确执行
public dynamic Gett300km(string sidx, string sord, int page, int rows)
{
return "";
}
//仿照上面GET的方法,写POST方法,却不能执行 应该怎么改才对? 参数全一样就是响应客户端请求
public dynamic Postt300km(string sidx, string sord, int page, int rows)
{
return ""
}
...........
}
//这是客户端Get请求,能顺利执行
Request URL:http://localhost:4133/api/Default3?_search=false&nd=1364353289015&rows=20&page=1&sidx=&sord=asc
Request Method:GET
Status Code:200 OK
Request Headersview source
Accept:application/json, text/javascript, */*; q=0.01
Accept-Charset:GBK,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:zh-CN,zh;q=0.8
Connection:keep-alive
Cookie:ASP.NET_SessionId=tj05khlfzvqulb4dylarg33u
Host:localhost:4133
Referer:http://localhost:4133/Default1
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.172 Safari/537.22
X-Requested-With:XMLHttpRequest
Query String Parametersview sourceview URL encoded
_search:false
nd:1364353289015
rows:20
page:1
sidx:
sord:asc
//这是客户端POST请求,报错的结果
Request URL:http://localhost:4133/api/Default3
Request Method:POST
Status Code:500 Internal Server Error
Request Headersview source
Accept:application/json, text/javascript, */*; q=0.01
Accept-Charset:GBK,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:zh-CN,zh;q=0.8
Cache-Control:max-age=0
Connection:keep-alive
Content-Length:60
Content-Type:application/x-www-form-urlencoded; charset=UTF-8
Cookie:ASP.NET_SessionId=tj05khlfzvqulb4dylarg33u
Host:localhost:4133
Origin:http://localhost:4133
Referer:http://localhost:4133/Default1
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.172 Safari/537.22
X-Requested-With:XMLHttpRequest
Form Dataview sourceview URL encoded
_search:false
nd:1364353130887
rows:20
page:1
sidx:
sord:asc
------解决方案--------------------报错的错误信息是什么?
------解决方案--------------------统一使用Request[param]进行获取
------解决方案--------------------sorry,我搞错了,web api木用过。
看看这个能解决问题吗
------解决方案--------------------代码有问题吧? 内部错误