Password Reset Portal SMS Gate Not Working RRS feed

  • Question

  • trying Microsoft code to enable One-Time Password with SMS Gate, no luck to make it work. Anyone can advise what's wrong of this code? 

    Customer sms gateway requires POST method with 3 parameters: "password", "hp" and "smsmessage"

    namespace Microsoft.IdentityManagement.Samples
        using System;
        using System.Collections.Generic;
        using System.Globalization;
        using System.Net;
        using System.Text;
        using Microsoft.IdentityManagement.SmsServiceProvider;
        using System.Web;
        using System.Security.Cryptography;
        using System.IO;

        public class SmsServiceProvider : ISmsServiceProvider
            public void SendSms(string mobileNumber,
                                string message,
                                Guid requestId,
                                Dictionary<string, object> deliveryAttributes)
                mySMSProvider.SendSms(mobileNumber, message);

        class mySMSProvider
            static string RequestURL = "";
            public static int SendSms(string userMobileNumber, string message)
                WebClient wc = new WebClient();
                string requestData;
                requestData = Microsoft.IdentityManagement.Samples.mySMSProvider.GetRequestData(userMobileNumber, message);
                byte[] postData = Encoding.ASCII.GetBytes(requestData);

                byte[] response = wc.UploadData(mySMSProvider.RequestURL, postData);
                string result = Encoding.ASCII.GetString(response);  // result contains the error text
                int returnValue = System.Convert.ToInt32(result.Substring(0, 6), NumberFormatInfo.InvariantInfo);
                return returnValue;
            public static string GetRequestData(string mobile, string message)
                string myrequestData;
                myrequestData = "password=" + "password123"
                     + "&hp=" + System.Web.HttpUtility.UrlEncode(mobile)
                     + "&smsmessage=" + System.Web.HttpUtility.UrlEncode(message);
                return myrequestData;


    Wednesday, September 10, 2014 5:07 AM


  • There is some "well known" issue if you put more than one class into the dll. Try to insert all the logic to the SmsServiceProvider class.

    Borys Majewski, Identity Management Solutions Architect (Blog: IDArchitect.NET)

    • Proposed as answer by Borys Majewski Friday, September 12, 2014 9:38 PM
    • Marked as answer by Jason2804 Wednesday, October 1, 2014 2:50 PM
    Thursday, September 11, 2014 4:59 PM