Last post Jan 31, 2018 12:46 AM by dlchase
Jan 30, 2018 09:28 PM|dlchase|LINK
We are troubleshooting a web page (.aspx) that handles processing a reply from their api. It is with a company called Clickatell and the sending of an SMS text via http url works perfectly. We also have a reply url that replies to our website with any reply
that to person receiving the sms text happens to send back. Problem is that we are getting the reply back but it is empty of any expected querystring values. We are trying to get answers but wanted to be sure that our process is coded correctly. I think
the below element is in the web.config file for re-routing the called page from ~/misc/ReplySMS.aspx to run an http handler named SMSReplyHandler.ashx
//in <system.web> section of web.config
<add url="~/misc/ReplySMS.aspx" mappedUrl="~/SMSReplyHandler.ashx"/>
We do get a reply back as I am creating an email to myself but the context.Request.QueryString("api_id") and others (see below) are returning nothing.
<%@ WebHandler Language="VB" Class="SMSReplyHandler" %>
Public Class SMSReplyHandler : Implements IHttpHandler
Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
context.Response.ContentType = "text/plain"
Dim strMOMessageID As String = ""
Dim strapiID As String = ""
'default TO address to web.config appsettings in case no email address found
Dim strTo As String = ConfigurationManager.AppSettings("shopemail")
Dim strToQS As String = ""
Dim strFrom As String = "email@example.com"
Dim strFromQS As String = ""
Dim strSubject As String = "SMS Reply from "
Dim strBody As String = ""
Dim strTextQS As String = ""
Dim strTimestamp As String = ""
Dim bolReplyUpdated As Boolean = False
Dim strEEmail As String = ""
Dim strSentBy As String = "AARON"
Dim strMessage As String = ""
If Not context.Request.QueryString("api_id") Is Nothing Then
strapiID = context.Request.QueryString("api_id")
If Not context.Request("from") Is Nothing Then
strFromQS = context.Request("from")
If Not context.Request("text") Is Nothing Then
strTextQS = context.Request("text")
strBody = "Message reply = " & strTextQS
If Not context.Request.QueryString("to") Is Nothing Then
strToQS = context.Request.QueryString("to")
If Not context.Request.QueryString("timestamp") Is Nothing Then
strTimestamp = context.Request.QueryString("timestamp")
If Not context.Request.QueryString("moMsgId") Is Nothing Then
strMOMessageID = context.Request.QueryString("moMsgId")
...rest of code left out...
Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
Jan 30, 2018 09:40 PM|mgebhard|LINK
Isn't this a super easy thing to test yourself? Add the URL with querystring parameters the browser address bar and press enter. Test both the aspx page and ashx to verify the rewrite and code are working as expected.
Also, look in the IIS logs to make sure the caller is sending the querystring values.
Jan 30, 2018 09:49 PM|dlchase|LINK
I looked in the log and found the following entry.
2018-01-30 21:31:32 192.168.0.7 GET /WebStatus/misc/ReplySMS.aspx - 80 - 220.127.116.11 Mozilla/5.0+(Windows+NT+6.1;+WOW64)+AppleWebKit/537.31+(KHTML,+like+Gecko)+Chrome/26.0.1410.64+Safari/537.31 200 0 0 10732
Jan 30, 2018 10:51 PM|mgebhard|LINK
Well, if you are using the W3C standard log format then it looks like the caller did not send the querystring. You probably should look into that...
Did you try testing the URL from your browser?
Jan 31, 2018 12:46 AM|dlchase|LINK
Yes, it appears to be an issue with the vendor. Thank you for your help.