4 Replies Latest reply on Nov 30, 2007 1:32 PM by ntsiii

    Running ASPX page through Flex

      Hi everyone. I just started using Flex this morning and have been looking around on development sites as well as reading articles to learn what I can.

      I have a mini web app in C#.NET that I would ultimately like to turn into an AIR app, but for now... baby steps. Since the non-Flex / Flash side of AIR only seems to like HTML and AJAX / JavaScript, I'd like to get my app running through Flex.

      Without providing all of the code, the app basically makes an HttpWebRequest to several pages and returns their status code. The ASPX page displays a list of URLs as well as whether the page returned a healthy status code or otherwise. It's a way for me to be alerted if any of the monitored pages go down.

      Can anyone provide a good starting point for me to run this through a Flex app? I guess ideally, instead of redeveloping the app in Flex, it would be better to try and parse the ASPX page into XML and then rebuild it. But as I am new to Flex, I am open to any suggestions.

        • 1. Re: Running ASPX page through Flex
          ntsiii Level 3
          Flex is primarily a client-side "presentation tier" technology. In other words, it is the user interface for an application.

          So we need to start by asking "what do you want to show the user". Is this the answer? "...displays a list of URLs as well as whether the page returned a healthy status code or otherwise..."

          If so, I advise just modifying your current ASPX app by removing all of the UI, and setting contentType to xml/text, to have it output xml. The Flex app would use HTTPService to send a request to the aspx page containing any parameters necessary. The aspx app runs its requests, builds an xml string and response.Writes it back to Flex.

          Flex then uses the xml data to build the display for the user. (set resultFormat="e4x" on the HTTPService tag)

          Using HTTPService with aspx as the back end for flex apps is my preferred architecture. It is fast reliable, and easy to code.

          Post back if you need any detail. I have some examples of communicating with and aspx back end on www.cflex.net.

          • 2. Re: Running ASPX page through Flex
            bhuber7 Level 1
            Thanks Tracy.

            That was a very helpful answer. I'm going to follow your guidance and see what I can do. If any problems arise that I can't seem to get around, I'll be sure to post back.

            I appreciate the help.

            • 3. Re: Running ASPX page through Flex
              bhuber7 Level 1
              Hi Tracy,

              Okay, so I'm back with a little status update. I think I have the .NET aspect under control. My code runs and spits out the desired result in XML. My node hierarchy is:


              In Flex, I'm a little lost. I have my document declared:

              <?xml version="1.0" encoding="utf-8"?>
              <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" initialize="statusCheck.send()">

              I have my HTTPService (which may or may not be right):

              <mx:HTTPService id="statusCheck" url="someUrl" resultFormat="e4x" result="resultHandler(event)" />

              What else do I need to display the data in the above XML?

              Thanks in advance!
              • 4. Re: Running ASPX page through Flex
                ntsiii Level 3
                Ok, first, declare an instance level variable to hold the data, so you can use it anywhere:
                private var _xmlStatusCheck:XML;

                in the event handler:
                private function resultHandler(event:ResultEvent):void {
                _xmlStatusCheck = XML(event.result);
                trace(_xmlStatusCheck.toXMLString()); //to be sue of what you have.

                If you can see your good xml in the trace then you have the hardest part done.
                How do you want to see your data? Tree? A datagrid?