Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/35.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/13.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
Asp.net 如何更改WebMethod参数的序列化程序_Asp.net_Json_Vb.net_Serialization_Json.net - Fatal编程技术网

Asp.net 如何更改WebMethod参数的序列化程序

Asp.net 如何更改WebMethod参数的序列化程序,asp.net,json,vb.net,serialization,json.net,Asp.net,Json,Vb.net,Serialization,Json.net,我在一些旧的网络代码中发现了一个问题。问题是默认序列化程序没有正确序列化日期。我想使用JSON.Net在我们的aspx代码中序列化web方法的参数。但是我不知道如何告诉它使用JSON.NET而不是使用默认的序列化程序 下面是我们代码的一个示例 <System.Web.Services.WebMethod()> _ <System.Web.Script.Services.ScriptMethod()> _ Public Shared Function Edi

我在一些旧的网络代码中发现了一个问题。问题是默认序列化程序没有正确序列化日期。我想使用JSON.Net在我们的aspx代码中序列化web方法的参数。但是我不知道如何告诉它使用JSON.NET而不是使用默认的序列化程序

下面是我们代码的一个示例

<System.Web.Services.WebMethod()> _
    <System.Web.Script.Services.ScriptMethod()> _
    Public Shared Function EditApplication(ByVal Application As ApplicationModel, ByVal Country As String, ByVal Language As String) As jsonResponse
        Dim r As New jsonResponse
        Dim g As New ApplicationRequest
        g.country = Country
        g.locale = Language
        g.platform = "Android"
        g.timestamp = ""
        g.transactionid = "abc123"
        ....
_
_
公共共享函数EditApplication(ByVal应用程序作为应用程序模型,ByVal国家作为字符串,ByVal语言作为字符串)作为jsonResponse
Dim r作为新的jsonResponse
Dim g作为新的应用程序请求
g、 国家
g、 语言环境=语言
g、 platform=“安卓”
g、 timestamp=“”
g、 transactionid=“abc123”
....

所以我需要ApplicationModel使用JSON.Net进行序列化。谢谢您的帮助。

不确定这是否有用(因为这是从REST web服务获取的),但您可以在OperationContract上定义它,如下所示: System.ServiceModel.Web.WebMessageFormat.Json

<OperationContract()> _
<WebGet(responseformat:=System.ServiceModel.Web.WebMessageFormat.Json)> _
_
_