I am building a SMS Getaway, and I am using SMS Enabler. So this is my example, a person sends a code via SMS. This code is looped in a SQL Server Database and checks if this code exists in this column, let's say on Database TEST, table TAGLE1, column CODES. If this code that this person exists in this column SMS Enabler replies a code that he is the winner, else is the code does not exists it replies "Try Again". I can only do this via .ashx file not .aspx file This is my code:
public class sms : IHttpHandler {
// This method is called each time a new SMS message arrives
public void ProcessRequest(HttpContext context) {
// form variables (contain all sms message information)
var sms = context.Request.Form;
// sender's number
string senderNumber = sms["sender"];
// sms message text
string messageText = sms["text"];
// SMS center timestamp in UTC. You can consider this
// as the date and time when the sender sent the message.
DateTime sentTime = DateTime.ParseExact(sms["scts"],
"yyyy'-'MM'-'dd HH':'mm':'ss", null);
// SMS center number (not supported when using SMS Enabler
// with a Nokia phone)
string smscNumber = sms["smsc"];
// Tag value. You can define this in SMS Enabler's settings,
// and use it to pass additional information.
string tag = sms["tag"];
/* TODO:
WRITE YOUR CODE FOR PROCESSING INCOMING SMS MESSAGES HERE */
// Sending a reply SMS. If you don't want to send a reply,
// just comment all the next lines out.
context.Response.ContentType = "text/plain";
// Add an X-SMS-To header to set the recipients of the reply.
// If not set, the reply is sent to the sender of the
// original SMS message.
// context.Response.AddHeader("X-SMS-To",
// "+97771234567 +15550987654");
// Write the text of the reply SMS message
// to the HTTP response output stream.
context.Response.Write("Reply SMS message");
}
public bool IsReusable {
get {
return false;
}
}
}
The only thing I want is how to bind data on .ashx file, loop through it, check it true or false and then reply.