0

"The response back will be posted directly to the application URL. Once posted, the application will need to take the status code and message ID from that information to determine the result of the SMS delivery."

Basically I send an http request to an API to send a text message and that website further sends delivery status to another URL I have given them . Now I want to receive the data sent to my application using http how can I do it in asp.net

Edited Part

 NameValueCollection pColl = Request.Params;

    // Iterate through the collection and add
    // each key to the string variable.
    for (int i = 0; i <= pColl.Count - 1; i++)
    {
        paramInfo += "Key: " + pColl.GetKey(i) + "<br />";



        // Create a string array that contains
        // the values associated with each key.
        string[]pValues = pColl.GetValues(i);


        // Iterate through the array and add
        // each value to the string variable.
        for (int j = 0; j <= pValues.Length - 1; j++)
        {

            paramInfo += "Value:" + pValues[j] + "<br /><br />";

        }
    }
Log(add, paramInfo);

Above code generates following response for me :

Key: result<br />Value:-5<br /><br />Key: transactionid<br        />Value:2a8b0559d2a6d96ff2250c5339356293<br /><br />Key: notification<br />Value:msgresult<br /><br />Key: messageid<br />Value:My test message.<br /><br />Key: botkey<br />Value:123456<br /><br />Key: ALL_HTTP<br />Value:HTTP_CONNECTION:keep-alive
HTTP_CONTENT_LENGTH:120
HTTP_CONTENT_TYPE:application/x-www-form-urlencoded
HTTP_ACCEPT:text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
HTTP_HOST:abcdef
HTTP_USER_AGENT:Java/1.6.0_21
HTTP_TRANSACTIONID:2a8b0559d2a6d96ff2250c5339356293
HTTP_MESSAGEID:95a8e9c37b9e449fe47e7d3acdd6f6e5
br /><br />Key: ALL_RAW<br />

And what I need from whole response if the value of Key : result which is -5

2 Answers 2

3

What your service provider is saying is that, they will call your page sending data(most probably POST) to your page.

Asp.net pages are by default called over http.

You can receive the parameters as follows:

protected void Page_Load(object sender, EventArgs e)
{
    var param1 = Request.Form["paramName"];
}

I am sure your service provider must have supplied the parameter names they will be posting.

Edit: Your edit makes it a lot easier. The result that you require is already part of Request.Params.

you can get it using

var result = Request.Params["result"];

Or even simpler

var result = Request["result"];

Note: Using Request.Params is expensive on the first call as it builds the NameValueCollection by adding parameters from the QueryString, Form, Cookie and ServerVariables.

Sign up to request clarification or add additional context in comments.

5 Comments

Yes and what if they send that data as a JSON load how can i recieve data send as JSON ?
It will still come as a string parameter. After receiving the JSON, you can parse it. If you can provide the exact communication, or link to the service provider website, I may be able to better guide you
smsified.com/sms-api-documentation/sending look at setting call back part of this page .
Hi sorry i edited your post by mistake instead of mine . Look at the edited part of my post i have given a lot of more details which will help in answer
Your edit simplified things a lot. Updated my answer, take a look
0

Then you can go for httpwebrequest and httpwebresponse as below

 HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create("http://Smsprovider");
 HttpWebResponse myResp = (HttpWebResponse)myReq.GetResponse();

Then you can see the delivery report by using myResp.StatusCode something like that for example if the message is delivered then myResp.StatusCode will be equal to OK you can see many properties like this http://msdn.microsoft.com/en-us/library/system.net.httpwebresponse.aspx

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.