Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.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#get方法a转换为post方法,从javascript调用_Javascript_C# 4.0_Http Post - Fatal编程技术网

将c#get方法a转换为post方法,从javascript调用

将c#get方法a转换为post方法,从javascript调用,javascript,c#-4.0,http-post,Javascript,C# 4.0,Http Post,我有一些c#api控制器,它们是当前的get()方法。我想把它们都转换成post。 在JavaScript方面,我可以看到它相当简单,但是需要一些指导,主要是c语言 下面是我当前在c#中的get()方法: 使用系统; 使用System.Collections.Generic; 使用System.Linq; Net系统; 使用System.Net.Http; 使用系统文本; 使用System.Web.Http; 使用DynAggrClient; 命名空间theapi.Controllers {

我有一些c#api控制器,它们是当前的get()方法。我想把它们都转换成post。 在JavaScript方面,我可以看到它相当简单,但是需要一些指导,主要是c语言

下面是我当前在c#中的get()方法:

使用系统;
使用System.Collections.Generic;
使用System.Linq;
Net系统;
使用System.Net.Http;
使用系统文本;
使用System.Web.Http;
使用DynAggrClient;
命名空间theapi.Controllers
{
公共类控制器:ApiController
{
//获取api/dim/?sid=sid&values=T/F
//
公共HttpResponseMessage Get()
{
字符串sid=UrlUtil.getParam(此为“sid”,”);
int返回值=0;
if(UrlUtil.getParam(这是“值”,“F”)=“T”)
返回值=1;
string resp=DynAggrClientAPI.dimRequest(sid,返回值);
var response=Request.CreateResponse(HttpStatusCode.OK);
response.Content=newstringcontent(resp,Encoding.UTF8,“application/json”);
返回响应;
}
}
}
[System.Web.Http.HttpPost]
公共类控制器:ApiController
{
//获取api/dim/?sid=sid&values=T/F
//
公共httpresponsemessagepost()
{
字符串sid=Request.Form[“sid”];
int返回值=0;
如果(请求表[“值”]=“T”)
返回值=1;
string resp=DynAggrClientAPI.dimRequest(sid,返回值);
var response=Request.CreateResponse(HttpStatusCode.OK);
response.Content=newstringcontent(resp,Encoding.UTF8,“application/json”);
返回响应;
}

}
请回答问题。我想要一个post()方法,但您的答案仍然是Get()。请求对象上没有Form()方法。我是否缺少名称空间?