当尝试向 ASP.NET asmx Web 服务发送 POST 请求时,我看到(在 Charles 和 Firebug 中)它以 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 方式通过。任何帮助,将不胜感激。谢谢。
最佳答案
来自 actionscript LR(URLRequest 类,方法属性):
注意:如果在 Flash Player 中运行并且引用的表单没有主体,Flash Player 会自动使用 GET 操作,即使该方法设置为 URLRequestMethod.POST。因此,建议始终包含“虚拟”主体以确保使用正确的方法。
你在使用那个“虚拟” body 吗?
关于actionscript-3 - AS3 POST 请求作为 GET 发送,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3557264/