dcsimg
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: XML.load works...XML.sendAndLoad doesn't (ASP.NET)

Hybrid View

  1. #1
    Member
    Join Date
    Feb 2002
    Posts
    48

    XML.load works...XML.sendAndLoad doesn't (ASP.NET)

    I have the following AS 2.0 class:

    In the constructor I have an XML object which is intended to recieve the XML from an ASP.NET page. When I run this code the way it is written, flash gives me a 'Error reading URL' error.

    However if I uncomment this line in the constructor, and have the .aspx page send back some test XML, it loads and parses fine.

    //this.loginReplyXML.load("http://xxxxxxxxx/VideoLaunch/loginTest.aspx");

    So what I can't understand, is why XML.load works, and XML.sendAndLoad doesn't. I thought it might be a security issue, but I can't find a clear answer on that either. Any help would be greatly appreciated!

    PHP Code:
    class logandload extends MovieClip {
        var inpUsername:TextField;
        var inpPassword:TextField;
        var responseField:mx.controls.TextArea;
        var submitButton:Button;
        var loginReplyXML:XML;
        public function logandload() {
            super();
            this.responseField.hScrollPolicy = "off";
            this.responseField.vScrollPolicy = "on";
            this.responseField.editable = false;
            this.responseField.text = "Login System Initialized...";
            this.submitButton.onRelease = this.submitLogin;
            //create reply XML object
            this.loginReplyXML = new XML();
            this.loginReplyXML.ignoreWhite = true;
            this.loginReplyXML.onLoad = this.handleReply;
            //this.loginReplyXML.load("http://xxxxxxx/VideoLaunch/loginTest.aspx");
        }
        public function submitLogin(evt:Object):Void {
            _root.loginMC.responseField.text += "\nCreating XML string....";
            var loginXML:XML = new XML();
            var rootNode:XMLNode = loginXML.createElement("login");
            var userNode:XMLNode = loginXML.createElement("user");
            var passNode:XMLNode = loginXML.createElement("pass");
            var userData:XMLNode = loginXML.createTextNode(_root.loginMC.inpUsername.text);
            var passData:XMLNode = loginXML.createTextNode(_root.loginMC.inpPassword.text);
            loginXML.appendChild(rootNode);
            rootNode.appendChild(userNode);
            userNode.appendChild(userData);
            rootNode.appendChild(passNode);
            passNode.appendChild(passData);
            _root.loginMC.responseField.text += "\nXML Data Created for Login:";
            _root.loginMC.responseField.text += loginXML.toString();
            _root.loginMC.responseField.vPosition = _root.loginMC.responseField.maxVPosition;
            loginXML.xmlDecl = "<?xml version=\"1.0\" ?>";
            
    loginXML.sendAndLoad("http://xxxxxxxx/VideoLaunch/loginTest.aspx"_root.loginMC.loginReplyXML);
        }
        public function 
    handleReply(success:Booleanevt:Error):Void {
            
    _root.loginMC.text += "\nReceived response from Server...";
            if (
    success) {
                
    _root.loginMC.responseField.text += _root.loginMC.loginReplyXML.toString();
                var 
    myUser:XMLNode _root.loginMC.loginReplyXML.firstChild.childNodes[0].firstChild.toString();
                var 
    myPass:XMLNode _root.loginMC.loginReplyXML.firstChild.childNodes[1].firstChild.toString();
                
    _root.loginMC.responseField.text += "\nUser Name is "+myUser;
                
    _root.loginMC.responseField.text += "\nPassword is "+myPass;
                
    _root.loginMC.responseField.vPosition _root.loginMC.responseField.maxVPosition;
            } else {
                
    _root.loginMC.responseField.text += "\nSomething went wrong!";
            }
        }
    }

  2. #2
    Senior Member tupps's Avatar
    Join Date
    Jan 2001
    Location
    Melbourne
    Posts
    2,035
    Is your .aspx returning the correct data? That would be my guess, debug your aspx page to see if the correct data is being returned. The xml doesn't come through as a standard parameter so this might be causing the error.

    Thanks

    Luke
    Flash-XML FAQ
    http://www.tupps.com/flash/faq/

  3. #3
    Member
    Join Date
    Feb 2002
    Posts
    48
    Thanks a lot for your idea. The .aspx was returning a good XML message, it turns out. I have solved the problem, and it turns out it was a security thing afterall caused by the XML that flash sent.

    Apparently ASP.NET tries to validate the safeness of whatever is being sent. You need to turn off that checking in the Page directive by setting validateRequest=false.

    I would prefer to actually validate the data and approve it somehow, but I am still looking into how to do that. For now this will have to do.
    -Best of luck with that...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center