use amf remoting with asp.net mvc

安稳与你 提交于 2019-12-10 11:58:30

问题


anybody knows if it is possible to do calls from flash to asp.net mvc actions using amf remoting ?

if yes, how? which technologies should be used and how to combine them

on the flash side it would be something like this:

    //Connect the NetConnection object
    var netConnection: NetConnection = new NetConnection();
    netConnection.connect("http://localhost:59147/Home/Index");

   //Invoke a call
   log("invoke call TestMethod");
   var responder : Responder = new Responder( handleRemoteCallResult, handleRemoteCallFault);
   netConnection.call('TestMethod', responder, "Test");

I tried this and it hits the action but I can't find the 'TestMethod' and "Test" anyware in the Request

Thank You


回答1:


I don't have a complete answer, but this could help you in the start.

You could use FluorineFx, that is a good start as it implements all the AMF stuff and it has AMFWriter/Reader, AMFDeserializer and so, play with them.

using System.Web.Mvc;
using FluorineFx.IO;

public class AMFFilterAttribute : ActionFilterAttribute
{
    public override void OnActionExecuting(ActionExecutingContext filterContext)
    {
        if (filterContext.HttpContext.Request.ContentType == "application/x-amf")
        {
            var stream = filterContext.HttpContext.Request.InputStream;

            var deserializer = new AMFDeserializer(stream);
            var message = deserializer.ReadAMFMessage();

            foreach (var body in message.Bodies) // not foreach, just the first one
            {
                filterContext.ActionParameters["method"] = body.Target;
                filterContext.ActionParameters["args"] = body.Content;
            }

            base.OnActionExecuting(filterContext);
        }
    }
}

[AMFFilter]
[HttpPost]
public ActionResult Index(string method, object[] args)
{
    return View();
}

This is just the first part. Returning binary data and stuff could be handled by some kind of custom ActionResult, but that one you know how to do from here AMF ActionResult for asp.net mvc ?

Good luck.



来源:https://stackoverflow.com/questions/10519617/use-amf-remoting-with-asp-net-mvc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!