2012-01-29 37 views
0

我试图让我的Flash应用程序向Web服务器发送请求,以便它可以获取一些信息。到目前为止,在阅读了一段时间和网络上的stackoverflow后,我写了一些代码,但它的工作并不正确。我只需要一点帮助就可以把它捆绑在一起。ActionScript 3.0使用MVC发送POST和从.Net 4获取数据

这里是我的web服务器

// 
    // POST: /Home/HoneyPot 
    [HttpPost] 
    public ActionResult HoneyPot(bool GetData) 
    { 
     //ViewBag. 
     return View(); 
    } 

这里是应该被提出请求的ActionScript代码控制器。

// get dynamic page element information 
var myData:URLRequest = new URLRequest("http://localhost:59418/HoneyPot"); 
myData.method = URLRequestMethod.POST; 

var vars:URLVariables = new URLVariables(); 

vars.Input = "GetData=true"; 

myData.data = vars; 
var loader:URLLoader = new URLLoader(); 
loader.dataFormat = URLLoaderDataFormat.VARIABLES; 
loader.addEventListener(Event.COMPLETE, gotPostData_Spiral); 
loader.load(myData); 

function gotPostData_Spiral(anEvent:Event):void 
{ 
    var postData = anEvent.target.data.myVar; 
} 

现在,当我运行Flash代码中,我得到这个输出回:

Error opening URL 'http://localhost:59418/HoneyPot'

Error: Error #2101: The String passed to URLVariables.decode() must be a URL-encoded query string containing name/value pairs.

at Error$/throwError()

at flash.net::URLVariables/decode()

at flash.net::URLVariables()

at flash.net::URLLoader/onComplete()

感谢您的帮助

回答

0

相反的:

vars.Input = "GetData=true"; 

尝试:

vars.GetData = "true"; 
+0

谢谢你的回复我试过了,从Adobe回来了这条消息: 打开URL'http:// localhost:59418/HoneyPot'时出错错误:错误#2101:字符串传递给URLVariables.decode )必须是包含名称/值对的URL编码查询字符串。 \t在错误$/throwError() \t在flash.net::URLVariables/decode() \t在flash.net::URLVariables() \t在flash.net::URLLoader/onComplete() – 2012-01-30 21:32:41