Get Json-Body From Post in ASP.NET 4.7

علی ذوالفقار
1402/12/20 16:18:06 (180)
Function Get_Json_Body() As Object
        '-> read data from request object 
        Dim Data As String
        Using reader = New System.IO.StreamReader(HttpContext.Current.Request.InputStream)
            Data = reader.ReadToEnd()
        End Using
        Try
            Return Newtonsoft.Json.JsonConvert.DeserializeObject(Of System.Dynamic.ExpandoObject)(Data) '-> valid json data 
        Catch ex As Exception            
            Return Newtonsoft.Json.JsonConvert.DeserializeObject(Of System.Dynamic.ExpandoObject)("") '-> empty json 
        End Try
    End Function        
Back