how could I run the ashx service with asp.Net c #?

0

Hi, I'm working on asp.net c # web, run this aspx service

so use this xml code, without redirecting

DateTime DiaActual;
            DiaActual = DateTime.Now;
            String VariableEnviar;
            String Obteneyear; String Mes; String Dia; String Hora; String Minuto; String Segundos;
            Obteneyear = DiaActual.Year.ToString();
            Mes = DiaActual.Month.ToString();
            Dia = DiaActual.Day.ToString();
            Hora = DiaActual.Hour.ToString();
            Minuto = DiaActual.Minute.ToString();
            Segundos = DiaActual.Second.ToString();


            VariableEnviar = "000000" + "-ASK" + "-" + Obteneyear + "-" + Mes + "-" + Dia + " " + Hora + ":" + Minuto + ":" + Segundos;

            string URLString = "https://robinacademia.com/p.ashx?o=63&e=2&f=pb&r=r_parameter&t=" + VariableEnviar;


            XmlTextReader reader = new XmlTextReader(URLString);
            string resultado = "";
            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                    case XmlNodeType.Element: // El nodo es un elemento.
                        resultado += "<" + reader.Name;

                        while (reader.MoveToNextAttribute()) // Lee los atributos.
                            Console.Write(" " + reader.Name + "='" + reader.Value + "'");
                        resultado += ">";
                        resultado += "\n";
                        break;
                    case XmlNodeType.Text: //Muestra el texto en cada elemento.
                        resultado += reader.Value;
                        break;
                    case XmlNodeType.EndElement: //Muestra el final del elemento.
                        resultado += "</" + reader.Name;
                        resultado += ">";
                        break;
                }
            }

But the bad thing that does not show me correctly mesage.

because if I link that link in my browser:

link 11: 12: 5

I have a different one, what I want is to be verified the same as shown in the browser when I place

Try also with this code but it looks the same:

 String Label;
            WebClient client = new WebClient();
            Label = client.DownloadString("https://robinacademia.com/p.ashx?o=63&e=2&f=pb&r=r_parameter&t=000000-ASK-2018-7-7 11:12:5");

    
asked by PieroDev 07.07.2018 в 18:26
source

1 answer

1
using System;
using System.Linq;
using System.Net;
using System.Xml.Linq;

namespace ReadXMLfromASHXhandler
{
    class Program
    {
        static void Main(string[] args)
        {
            String Label;
            WebClient client = new WebClient();
            Label = client.DownloadString("https://robinacademia.com/p.ashx?o=63&e=2&f=pb&r=r_parameter&t=000000-ASK-2018-7-7 11:12:5");

            XDocument doc = XDocument.Parse(Label);

            XElement code = doc.Descendants("code").FirstOrDefault();
            XElement msg = doc.Descendants("msg").FirstOrDefault();

            string codeValue = code.Value;
            string msgValue = msg.Value;           
            Console.WriteLine(codeValue);
            Console.WriteLine(msgValue);

            Console.ReadLine();
        }
    }
}

Recommended reading:

answered by 07.07.2018 / 23:18
source