public ActionResult doCall(string Name, string phoneBgn, string phoneEnd) { try { AMS.Profile.Ini Ini = new AMS.Profile.Ini(AppDomain.CurrentDomain.BaseDirectory + "\\Callback.ini"); if (!Ini.HasSection("COMMON")) { Ini.SetValue("COMMON", "account_id", "12345"); Ini.SetValue("COMMON", "api_key", "some-as-uuid-string"); } string account_id = Ini.GetValue("COMMON", "account_id", "12345"); string api_key = Ini.GetValue("COMMON", "api_key", "some-as-uuid-string"); string url = "https://api.voximplant.com/platform_api/StartScenarios/?account_id=" + account_id + "&api_key=" + api_key + "&rule_id=135498&script_custom_data=" + phoneBgn + "%3A" + phoneEnd + ""; var request = (HttpWebRequest)WebRequest.Create(url); var response = (HttpWebResponse)request.GetResponse(); var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd(); Call theCall = Call.GetByCall(phoneBgn, phoneEnd); if (theCall == null) { theCall = new Call(); theCall.Name = Name; theCall.phoneBgn = phoneBgn; theCall.phoneEnd = phoneEnd; theCall.Save(); } else { theCall.CallsCount++; theCall.Name = Name; theCall.Update(); } var serializer = new JavaScriptSerializer(); // For simplicity just use Int32's max value. // You could always read the value from the config section mentioned above. serializer.MaxJsonLength = Int32.MaxValue; var resultData = new { phone_bgn = phoneBgn, phone_end = phoneEnd, result = responseString }; var result = new ContentResult { Content = serializer.Serialize(resultData), ContentType = "application/json" }; return(result); } catch (Exception ex) { var serializer = new JavaScriptSerializer(); // For simplicity just use Int32's max value. // You could always read the value from the config section mentioned above. serializer.MaxJsonLength = Int32.MaxValue; var resultData = new { phone_bgn = phoneBgn, phone_end = phoneEnd, error = ex.Message }; var result = new ContentResult { Content = serializer.Serialize(resultData), ContentType = "application/json" }; return(result); } }