Base solution for your next web application
Open Closed

Controller action only giving post response via localhost #3742


User avatar
0
ervingayle created

I have a AspZero .net core v4.3 project with the following action in my controller. The goal is to output XML in the exact way that is needed for my external provider to process it accordingly. Initially adding the [DontWrapResult] helps me to get the output closer to what I need. However, I notice that when I publish the solution I am unable to view the method output (400 bad request) and I only get a response (200) when I access via localhost.

I have an Index() action that is working fine so this is not an issue with routes at least to the controller in my opinion.

// POST: Broadcast/Play
        [HttpPost]
        [DontWrapResult]
        public string Play(string recordingUrl)
        {

            var response = new VoiceResponse();
            response.Play(recordingUrl);

            //return (response.ToString());
            //return new XmlActionResult(response);
            //return new TwiMLResult(response.ToString());
            //return new Twilio.TwiML.VoiceResponse().Say(response.ToString());
            //TwilioController TwilioController = new TwilioController();
            //var res = TwilioController.TwiML(response,Encoding.UTF8);
            //return res.Data;

            //var data = LoadFromString(response.ToString(), Encoding.UTF8);

            //return data;

            var res = response.ToString();

            return res;

        }
        private static XDocument LoadFromString(string twiml, Encoding encoding)
        {
            var stream = new MemoryStream(encoding.GetBytes(twiml));

            var settings = new XmlReaderSettings();
            settings.DtdProcessing = DtdProcessing.Prohibit;

            var reader = XmlReader.Create(stream, settings);
            return XDocument.Load(reader);
        }

What am I doing wrong here?


1 Answer(s)
  • User Avatar
    0
    alper created
    Support Team

    hi

    it's hard to guess what you are doing wrong. could you share us your host's error log.