将参数从asp.net页面传递给flex应用程序

时间:2010-04-22 10:41:07

标签: asp.net flex

我有一个asp.net页面,我从谁登录后获取user_id。现在我需要将此user_id传递给在asp.net页面中作为.swf运行的flex应用程序。 如何在我的flex应用程序中的变量中获取此user_id。 或者什么是使user_id进入flex的最佳方法。 感谢

2 个答案:

答案 0 :(得分:1)

你创建另一个asp.net页面,在这个页面上你得到那个用户ID并在页面上写。 从flex应用程序使用HTTPService命中该asp.net页面并获得该响应。 在那个回复中你得到那个用户ID ...

var httpservice:HTTPService=new HTTPService();
     httpservice.url="http://xyz.com/getuser.aspx;
     httpservice.useProxy=false;
     httpservice.method="Post";
     httpservice.resultFormat="text";
     httpservice.addEventListener(FaultEvent.FAULT,GettingException);
     httpservice.addEventListener(ResultEvent.RESULT,Result);
     httpservice.send();


private function GettingException(e:FaultEvent){

 Alert.show(e.fault.message, "Could not load page");

}
 private function Result(e:ResultEvent){

 var Result:String = e.result.toString();
 Alert.show(Result);

}

答案 1 :(得分:1)

如果链接到包含swf的ASP.Net页面,您可以对user_id进行模糊处理并将其传递给查询字符串,或者使用映射到user_id的guid。 Flex可以从查询字符串中读取值。见this article.

或者您可以将user_id值粘贴到flashvars中(ASP.Net页面应该有访问权限)并从那里读取它。

userID = Application.application.parameters.user_id;
相关问题