Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7928615
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T19:47:14+00:00 2026-06-03T19:47:14+00:00

I’m building a mvc application which will communicate with flash via AMF, anybody knows

  • 0

I’m building a mvc application which will communicate with flash via AMF,
anybody knows if there is any AMF ActionResult available on the web ?

EDIT:

using @mizi_sk answer (but without using IExternalizable) I did this ActionResult:

public class AmfResult : ActionResult
{
    private readonly object _o;

    public AmfResult(object o)
    {
        _o = o;
    }

    public override void ExecuteResult(ControllerContext context)
    {
        context.HttpContext.Response.ContentType = "application/x-amf";
        using (var ms = new MemoryStream())
        {
            // write object
            var writer = new AMFWriter(ms);
            writer.WriteData(FluorineFx.ObjectEncoding.AMF3, _o);
            context.HttpContext.Response.BinaryWrite(ms.ToArray());
        }
    }
}

but the response handler on the flash side doesn’t get hit.

in Charles at the Response->Amf tab I see this error:

Failed to parse data (com.xk72.amf.AMFException: Unsupported AMF3 packet type 17 at 1)

this is the raw tab:

 HTTP/1.1 200 OK 
 Server: ASP.NET Development Server/10.0.0.0 
 Date: Mon, 14 May 2012 15:22:58 GMT 
 X-AspNet-Version: 4.0.30319
 X-AspNetMvc-Version: 3.0 
 Cache-Control: private 
 Content-Type:application/x-amf 
 Content-Length: 52 
 Connection: Close

  3/bingo.model.TestRequest param1coins name

and the Hex tab:

00000000  11 0a 33 2f 62 69 6e 67 6f 2e 6d 6f 64 65 6c 2e     3/bingo.model.
00000010  54 65 73 74 52 65 71 75 65 73 74 0d 70 61 72 61   TestRequest para
00000020  6d 31 0b 63 6f 69 6e 73 09 6e 61 6d 65 01 04 00   m1 coins name   
00000030  06 05 6a 6f                                         jo            
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T19:47:16+00:00Added an answer on June 3, 2026 at 7:47 pm

    The trick is to use FluorineFx.IO.AMFMessage with AMFBody as a result object and set a Content property.

    You can see this in Charles proxy with other working examples (I’ve used great WebORB examples, specifically Flash remoting Basic Invocation AS3)

    I’ve updated AMFFilter to support Response parameter that AMFBody needs. Maybe it could be solved more elegantly by some current context cache, don’t know.

    Code follows:

    public class AmfResult : ActionResult
    {
        private readonly object _o;
        private readonly string _response;
    
        public AmfResult(string response, object o)
        {
            _response = response;
            _o = o;
        }
    
        public override void ExecuteResult(ControllerContext context)
        {
            context.HttpContext.Response.ContentType = "application/x-amf";
    
            var serializer = new AMFSerializer(context.HttpContext.Response.OutputStream);
            var amfMessage = new AMFMessage();
            var amfBody = new AMFBody();
            amfBody.Target = _response + "/onResult";
            amfBody.Content = _o;
            amfBody.Response = "";
            amfMessage.AddBody(amfBody);
            serializer.WriteMessage(amfMessage);
        }
    }
    

    For this to work, you need to decorate method on the controller with AMFFilter

    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();
    
                var body = message.Bodies.First();
                filterContext.ActionParameters["target"] = body.Target;
                filterContext.ActionParameters["args"] = body.Content;
                filterContext.ActionParameters["response"] = body.Response;
    
                base.OnActionExecuting(filterContext);
            }
        }
    }
    

    which would look something like this

    [AMFFilter]
    [HttpPost]
    public ActionResult Index(string target, string response, object[] args)
    {
        // assume target == "TestMethod" and args[0] is a String
        var message = Convert.ToString(args[0]);
        return new AmfResult(response, "Echo " + message);
    }
    

    Client side code for reference

    //Connect the NetConnection object
    var netConnection: NetConnection = new NetConnection();
    netConnection.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
    netConnection.connect("http://localhost:27165/Home/Index");
    
    //Invoke a call
    var responder : Responder = new Responder( handleRemoteCallResult, handleRemoteCallFault);
    netConnection.call('TestMethod', responder, "Test");
    
    private function onNetStatus(event:NetStatusEvent):void {
        log(ObjectUtil.toString(event.info));
    }
    
    private function handleRemoteCallFault(...args):void {
        log(ObjectUtil.toString(args));
    }
    
    private function handleRemoteCallResult(message:String):void {
        log(message);
    }
    
    private static function log(s:String):void {
        trace(s);
    }
    

    If you would like to return fault, just change this line in AMFResult

    amfBody.Target = _response + "/onFault";
    

    I like ObjectUtil.toString() formatting, but just remove it if you don’t have Flex linked.

    BTW, do you really need this in ASP.NET MVC? Maybe simple ASHX handler would suffice and performance would be better, I don’t know. The MVC architecture is a plus I presume.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I would like to run a str_replace or preg_replace which looks for certain words
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;
I need a function that will clean a strings' special characters. I do NOT

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.