2012-01-29 38 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