Hi,
im wondering if is possible to return a serialized AMF object in a control action in ASP.net MVC anyone as tried this before?
thanks in advance.
Hi,
im wondering if is possible to return a serialized AMF object in a control action in ASP.net MVC anyone as tried this before?
thanks in advance.
I have little to no experience with MVC but I have done some testing with writing AMF data to a Flash client. What I did was to build a Generic Handler which used ByteArray class in FluorineFX. I created an object instance and wrote it to the ByteArray with WriteObject(). I then wrote the data of the ByteArray to the Response Stream. In Flash I then used a standard URLLoader and used ReadObject() from the (URLLoader.data as ByteArray) and I had my object deserialized and ready to go. (Of course I had to do all the RemoteClass and registerClassAlias muck first)
My guess is that the MVC Action lets you access the Response Stream as well so you should be set.
I have no idea what an AMF object is (yes, i can google it but i won't). BUT, u can serialize any object in ASP.MVC. For example, returning an JSON object is an example of using the built in serialization.
check this previous SO question out:
public ActionResult MyAction()
{
...
// Populate myObject
return new JsonResult{ Data = myObject };
}
So the trick here, is that you need to make sure all the objects inside one of these AMF object can be serialised. If not, then don't forget you can return a serialised anonymous object.
eg.
public ActionResult MyAction()
{
...
// Populate myObject
return new JsonResult
{
Data = new
{
Id = object.Id,
Name = object.FirstName + ' ' object.Surname,
.... etc ....
}
};
}
hth.
You can also create your own ActionResult classes, if the existing ones don't allow you to emit the format that you need.
This site has information on creating custom ActionResults: http://blogs.msdn.com/jowardel/archive/2009/03/11/asp-net-rss-actionresult.aspx