2010-08-24 178 views
1

当试图向ASP.NET asmx Web服务发送POST请求时,我看到(在Charles和Firebug中)它以GET的形式发送。AS3 POST请求作为GET发送

这里是我的AS3

public function save(page:SharedPageVO, callback :Function = null): void { 
    var req:URLRequest = new URLRequest("service.asmx/CreateSharedPage"); 
    req.data = page; 
    req.method = URLRequestMethod.POST; 
    if (callback != null) 
    { 
    //handle removing the event here instead of there 
    this.complete = callback; 
    DataService.instance.addEventListener(Event.COMPLETE, onComplete); 
    } 
    DataService.instance.load(req); 
} 

public var complete:Function; 
private function onComplete(e:Event) 
{ 
if (complete != null) complete(e); 
complete = null; 
DataService.instance.removeEventListener(onComplete); 
} 

这似乎与闪光灯,因为它正在发生的事情甚至去到服务器之前的一个问题。我已经将这个上传到测试服务器,我仍然看到它通过GET。任何帮助,将不胜感激。谢谢。

+5

你的表格定义了一个body,对吧?从[URLRequest](http://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/flash/net/URLRequest.html#method)文档:“注意:如果在Flash Player中运行并且引用的表单没有正文,即使该方法设置为URLRequestMethod.POST,Flash Player也会自动使用GET操作。“ – Stephen 2010-08-24 14:08:42

+0

谢谢Stephen,就是这样。 – Skawful 2010-08-24 15:21:38

回答

1

从ActionScript LR(URLRequest类,方法,属性):

注:如果在Flash Player和引用的形式运行没有正文,Flash播放器会自动使用GET操作,即使该方法被设置为URLRequestMethod .POST。出于这个原因,建议始终包含一个“虚拟”主体以确保使用正确的方法。

您是否在使用“虚拟”身体?