<%@ WebHandler Language="C#" Class="SendOtp" %> using System; using System.Web; using System.Data; using System.Data.SqlClient; using System.Configuration; using System.Net; using Newtonsoft.Json; public class SendOtp : IHttpHandler { private string connectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; public void ProcessRequest(HttpContext context) { // CORS headers so the Flutter app can call this endpoint context.Response.Headers.Add("Access-Control-Allow-Origin", "*"); context.Response.Headers.Add("Access-Control-Allow-Headers", "Content-Type, Accept"); context.Response.Headers.Add("Access-Control-Allow-Methods", "GET, OPTIONS"); context.Response.ContentType = "application/json"; if (context.Request.HttpMethod == "OPTIONS") { context.Response.StatusCode = 200; context.Response.End(); return; } string memberId = context.Request.QueryString["member_id"]; string mobile = context.Request.QueryString["mobile"]; // If mobile not supplied, look it up by member ID if (string.IsNullOrEmpty(mobile) && !string.IsNullOrEmpty(memberId)) { using (SqlConnection con = new SqlConnection(connectionString)) { con.Open(); string query = "SELECT top 1 Mobile_1 FROM Memberslist WHERE Ndbano = @id"; SqlCommand cmd = new SqlCommand(query, con); cmd.Parameters.AddWithValue("@id", memberId); object mobObj = cmd.ExecuteScalar(); if (mobObj != null && mobObj != DBNull.Value) { mobile = mobObj.ToString(); } } } if (string.IsNullOrEmpty(mobile) || mobile == "0") { context.Response.StatusCode = 400; context.Response.Write(JsonConvert.SerializeObject(new { success = false, error = "Mobile number not found or invalid." })); return; } // Generate 4-digit OTP string otp = new Random().Next(1000, 9999).ToString(); // Exact approved DLT template & gateway settings compiled inside the live Newdelhibarassocia.dll: string text = "Dear User, this is your OTP " + otp + ". Do Not share this with anyone. TEAM NDBA"; string smsResponse = ""; try { using (WebClient client = new WebClient()) { string url = "http://hindit.co.in/API/pushsms.aspx?loginID=P1NDBA&password=6522651&mobile=" + mobile + "&text=" + HttpUtility.UrlEncode(text) + "&senderid=NDBATM&route_id=2&Unicode=0&IP=122.1.1.1&Template_id=1207173210411979025"; smsResponse = client.DownloadString(url); } } catch (Exception ex) { smsResponse = "SMS error: " + ex.Message; } context.Response.Write(JsonConvert.SerializeObject(new { success = true, mobile = mobile, otp = otp, smsResponse = smsResponse })); } public bool IsReusable { get { return false; } } }