C# JSON特权绘制无效。在AJAX中,使用jquery数据表在ASP.NET webforms中调用Webmethod
我正在尝试在ASP.NET webforms测试应用程序中实现jquery Datatables.NET的服务器端处理 使用以下代码: Jquery: (在我的AjaxTest.aspx.cs中): 班长: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
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"}