I am hopeful someone here can assist me with getting Newtonsoft.json working on my website.
Going to the URL for /default.aspx
The page loads, and I get this error.
Compiler Error Message: BC30002: Type 'JObject' is not defined.
Source Error:
Line 44: Response.Write("Server is up | ")
Line 45: json = New System.Net.WebClient().DownloadString("http://192.168.5.10:8007/101/metadata")
Line 46: Dim parsejson As JObject = JObject.Parse(json) '<== ERROR ON THIS LINE
The code works in Visual Studio.
It does not work on `Windows 2016 Server Core` running `IIS 10`.
Code line: `Dim parsejson As JObject = JObject.Parse(json)`
I'm using this code here. (From VB.NET Code To Parse Child Node Of JSON Last code on the page. NO [Brackets] only {Curly Brackets})
Imports System.Net
Imports Newtonsoft.Json.Linq
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12
Dim json As String = New System.Net.WebClient().DownloadString("https://reqres.in/api/products/3")
Dim parsejson As JObject = JObject.Parse(json) ' THIS LINE GIVES THE ERROR
Dim thename = parsejson.SelectToken("data.name").ToString()
txt1.Text = "Name Is " + thename
End Sub
End Class
Parsing the JSON from the link in the code. (Broken into lines to fit code better) Here is the actual JSON link.
{
"data": {
"id": 3,
"name": "true red",
"year": 2002,
"color": "#BF1932",
"pantone_value": "19-1664"
},
"support": {
"url": "https://reqres.in/#support-heading",
"text": "To keep ReqRes free, contributions towards server costs are appreciated!"
}
}
I have even added this to my web.config.
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-10.0.0.0" newVersion="13.0.3.27908" />
</dependentAssembly>
</assemblyBinding>
</runtime>
But none of this seems to work on a web server.
It works in Visual Studio, but not by going to the site on a web server.