如何在帖子中将参数发布到C#

时间:2018-06-07 10:20:25

标签: c# twilio

我有来自Twilio.com的代码来拨打电话。但是我如何发布一些可以用参数击中[HttpPost]函数的参数。

// Twilio请求

            var call = CallResource.Create(
                            method: Twilio.Http.HttpMethod.Post,
                            url: new System.Uri(URL),
                            to: new Twilio.Types.PhoneNumber(To),
                            from: new Twilio.Types.PhoneNumber("XXXXXXXXXX")
                            );

//我的方法返回TWiml

 [Route("~/Index/{message?}/{Voice?}/{Language?}")]
        [HttpPost]
        public ActionResult Index(string Message, string Voice, string Language)
        {
            //initializing Voice Response For creating XML
            var response = new VoiceResponse();

            if ((Voice != string.Empty && Voice != "0") && (Voice == "0"))
            {
                //Combining dynamic Message and selecting voice for reading message
                response.Say(Message, voice: Voice);
                var XML = new TwiMLResult(response.ToString());
                return XML;
            }
            if ((Voice != string.Empty && Voice != "0") && (Voice != string.Empty && Voice != "0"))
            {
                //Combining dynamic Message and selecting voice for reading message
                response.Say(Message, voice: Voice, language: Language);
                var XML = new TwiMLResult(response.ToString());
                return XML;
            }
            if ((Voice == string.Empty || Voice == "0") && (Voice == string.Empty || Voice == "0"))
            {
                //Combining dynamic Message and selecting voice for reading message
                response.Say(Message);
                var XML = new TwiMLResult(response.ToString());
                return XML;
            }
            return null;
            //}
            //else
            //{
            //    response.Say("Some Technical problem, please contact administrator");
            //    var XML = new TwiMLResult(response.ToString());
            //    return XML;
            //}
        }

0 个答案:

没有答案