Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/316.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#WebMethod中获取POST数据?_C#_Jquery_Asp.net_Ajax_Post - Fatal编程技术网

如何在C#WebMethod中获取POST数据?

如何在C#WebMethod中获取POST数据?,c#,jquery,asp.net,ajax,post,C#,Jquery,Asp.net,Ajax,Post,我需要使用jqueryajax请求发布值,以便在C#代码隐藏中进行处理。我可以发送数据,但我不知道如何从C#WebMethod内部检索数据 var cliente; $.post( "../Dados/GetDados.aspx/GetClienteById", { Id: id }, function(dado) { cliente = dado; }); C#代码: 将其添加为参数 [WebMethod] [Scrip

我需要使用jqueryajax请求发布值,以便在C#代码隐藏中进行处理。我可以发送数据,但我不知道如何从C#WebMethod内部检索数据

var cliente;
$.post(
    "../Dados/GetDados.aspx/GetClienteById",
    {
        Id: id
    },
    function(dado) {
        cliente = dado;
    });
C#代码:

将其添加为参数

[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public static string GetClienteById(int id)
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public static string GetClienteById(int id)