2017-09-17 26 views
1

我有一个遗留的ASP.NET Web窗体应用程序,它有一个Web服务来检索json中的数据。此外,发送到此Web服务的数据将作为json发送。 Web服务是一个真正的ASPX页面,获取数据作为发布表单数据:具有自定义JSON Web服务器的Kendo UI网格 - “未捕获的TypeError:this.replace不是函数”

json = Server.UrlDecode(Request.Form.ToString()) 

在剑道的UI我传递的参数如下:

transport: { 
    read: { 
     url: "MyService.aspx", 
     dataType: "json", 
     type: "POST", 
     data: JSON.stringify(GetRequestParams()) 
    } 
} 

JSON.stringify的值(GetRequestParams ())是

"{"Header":{"Method":"getfiles"},"Body":{"Data":{},"MaxResults":10,"PageNum":"1","FolderID":"14","SearchString":"","SearchSubFolders":false,"DepartmentID":"333333"},"ApiBaseUrl":"/Api3/"}" 

然而,这提供了以下JavaScript错误:“未捕获类型错误:this.replace是不是一个函数” 如果我通过数据,而不字符串化我t个第一,不会有一个JavaScript错误,但在服务器端,而不是JSON,我得到:

$inlinecount=allpages&Header[Method]=getfiles&Body[MaxResults]=10&Body[PageNum]=1&Body[FolderID]=14&Body[SearchString]=&Body[SearchSubFolders]=false&Body[DepartmentID]=333333&ApiBaseUrl=/Api3/&GetAjaxData=&$top=20 

有没有人有一个想法如何,我可以通过使用传输自定义的数据对象。使用Kendo-UI读取选项,这样我就可以解码服务器端的数据对象而没有问题?

或者任何建议的方式与asp.net形式以任何其他方式完成此任务?

+0

你有没有想过什么?我与MVC项目有同样的问题 –

回答

0

我确实找到了解决办法,但不是100%,因为我最终没有使用Kendo。我可以从我的代码,我没有看到的是:

来传递数据:data: GetRequestParams()(不字符串化)

在后面的代码我会确定这是否从剑道来到这个(VB.Net):

If (Request.Form("Header[Method]") IsNot Nothing AndAlso Request.Form("Header[Method]").ToLower() = "getfiles") Then 
     KendoRequest = True 
Else 

而且比得到的参数是这样的:

If Request.Form("Body[PageNum]") IsNot Nothing Then 
    PageNum = Convert.ToInt32(Request.Form("Body[PageNum]")) 
End If 

If Request.Form("Body[FolderID]") IsNot Nothing Then 
    FolderID = Convert.ToInt32(Request.Form("Body[FolderID]")) 
End If 

不漂亮,但它的工作。

相关问题