Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/270.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# JSON特权绘制无效。在AJAX中,使用jquery数据表在ASP.NET webforms中调用Webmethod_C#_Jquery_Asp.net_Ajax_Datatables - Fatal编程技术网

C# JSON特权绘制无效。在AJAX中,使用jquery数据表在ASP.NET webforms中调用Webmethod

C# JSON特权绘制无效。在AJAX中,使用jquery数据表在ASP.NET webforms中调用Webmethod,c#,jquery,asp.net,ajax,datatables,C#,Jquery,Asp.net,Ajax,Datatables,我正在尝试在ASP.NET webforms测试应用程序中实现jquery Datatables.NET的服务器端处理 使用以下代码: Jquery: (在我的AjaxTest.aspx.cs中): 班长: public class Person { public string Name { get; set; } public string FirstName { get; set; } public override string T

我正在尝试在ASP.NET webforms测试应用程序中实现jquery Datatables.NET的服务器端处理

使用以下代码: Jquery:

(在我的AjaxTest.aspx.cs中):

班长:

public class Person
    {
        public string Name { get; set; }
        public string FirstName { get; set; }

        public override string ToString()
        {
            return string.Format("{0} {1}", this.FirstName, this.Name);
        }

    }
我的AjaxTest.aspx如下所示:

<table class="table table-hover table-striped" id="PersonsTable">
                <thead>
                    <tr>
                        <th>Vooraam</th>
                        <th>Naam</th>
                    </tr>
                </thead>
                <tbody>

                </tbody>
            </table>

有人知道我做错了什么吗?

尝试在静态方法之上添加
[ScriptMethod(UseHttpGet=true,ResponseFormat=ResponseFormat.Json)]

你应该参考这个问题,好的,但这并不能回答问题。我找不到一个使用datatables/ajax/c#(asp.net)的工作示例,那么我也帮不了你,因为我对asp一无所知。抱歉,没问题,无论如何,请尝试在静态方法的顶部添加
[ScriptMethod(UseHttpGet=true,ResponseFormat=ResponseFormat.Json)]
public class Person
    {
        public string Name { get; set; }
        public string FirstName { get; set; }

        public override string ToString()
        {
            return string.Format("{0} {1}", this.FirstName, this.Name);
        }

    }
<table class="table table-hover table-striped" id="PersonsTable">
                <thead>
                    <tr>
                        <th>Vooraam</th>
                        <th>Naam</th>
                    </tr>
                </thead>
                <tbody>

                </tbody>
            </table>
{"Message":"Invalid JSON primitive: draw.","StackTrace":"   at System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializePrimitiveObject()\r\n   at System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializeInternal(Int32 depth)\r\n   at System.Web.Script.Serialization.JavaScriptObjectDeserializer.BasicDeserialize(String input, Int32 depthLimit, JavaScriptSerializer serializer)\r\n   at System.Web.Script.Serialization.JavaScriptSerializer.Deserialize(JavaScriptSerializer serializer, String input, Type type, Int32 depthLimit)\r\n   at System.Web.Script.Serialization.JavaScriptSerializer.Deserialize[T](String input)\r\n   at System.Web.Script.Services.RestHandler.GetRawParamsFromPostRequest(HttpContext context, JavaScriptSerializer serializer)\r\n   at System.Web.Script.Services.RestHandler.GetRawParams(WebServiceMethodData methodData, HttpContext context)\r\n   at System.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext context, WebServiceMethodData methodData)","ExceptionType":"System.ArgumentException"}