I have the following call to an ASPX page. The ASPX page does some stuff and returns some JSON. All of that works just fine and we won’t be changing that model. However the JSON is static as we’re not consuming the parameters at this point.
Within the ASPX page, how do I access the data passed to the url? For example, the varData below contains a referenceId. How do I access the value of referenceId inside the ASPX page?
function CallService()
{
$.ajax(
{
url : varUrl,
type : varType,
cache : false,
data : varData,
contentType : varContentType,
processdata : varProcessData,
dataType : varDataType,
async : false,
success : function(response) {
console.log(response);
ProcessParameters(response);
},
error : function(err) {
//alert("error condition triggered");
console.log(err);
},
complete : function() {
//alert("complete");
console.log("Complete!");
}
})
}
All the parameters above are set in this function:
function CallDlReportingService() {
varGuid = '12345678-1234-4567-8901-123456789012';
varType = "GET";
varUrl = "http://webServerA/page1.aspx";
varData = '{"referenceId": "' + varGuid + '"}';
varContentType = "application/json; charset=utf-8";
varDataType = "text";
varProcessData = true;
CallService();
}
Normally if you perform a GET request, the data is encoded in the url directly in the form of query string parameters (key-value pairs) like
So on the server-side you can just normally parse your parameters by using the
Page.Request.QueryStringcollection.In your specific case, you’re trying to send JSON data in a GET request, which is somehow not so convenient because your end-result (assuming “varGuid”=abc) would look like
This makes it difficult to parse. If possible you should change your
varDatapart s.t. it looks like