Classic ASP to Read JSON Request Body and Write JSON Response
Here’s a Classic ASP example using Chilkat to read an incoming JSON request body (such as from a POST), load it into a Chilkat JsonObject, and then write the JSON to an application/json response:
<% If Request.TotalBytes > 0 Then ' Read the JSON request body into a Chilkat BinData object. set bd = Server.CreateObject("Chilkat_9_5_0.BinData") bd.AppendBinary(Request.BinaryRead(Request.TotalBytes)) ' Load a Chilkat JsonObject from the JSON in the BinData. set json = Server.CreateObject("Chilkat_9_5_0.JsonObject") json.LoadBd(bd) ' Do whatever is needed with the JSON. ' In this example, we'll just echo the JSON to the response. Response.ContentType = "application/json" json.EmitCompact = 0 Response.Write json.Emit() End If %>
Note: The Chilkat ActiveX DLL must be registered (regsvr32) on your server where the above code runs. If you don’t know whether ASP is running 32-bit or 64-bit, then download and register both the Chilkat 32-bit ActiveX and 64-bit ActiveX. See https://www.chilkatsoft.com/downloads_ActiveX.asp
Make sure to “Run as Administrator” the .bat script that does the registration. The registration must happen in the local machine registry (not the current logged-on user registry) in order for IIS to see it.