Click here to Skip to main content
15,891,976 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi!

I have a web portal, that is based on MVC and has embedded Silverlight app on one of it's page.

SL application generate file, that should be sent to server by calling MVC action.

What I have tried....
Code in SL app:

C#
HtmlPage.Window.Invoke("SendNewImage", new object[] { bitmap.PixelWidth, bitmap.PixelHeight, stream.ToArray()});


SendNewImage function in JS:

JavaScript
function SendNewImage(width, height, pixels) {
    $.post("/Files/UploadImage", { 'pixels[]': pixels },
    function (success) {
    },"json"
  );


MVC action:
C#
[AcceptVerbs(HttpVerbs.Post)]
public JsonResult UploadImage(byte[] pixels)
{

    return Json(new object[] {});
}


Problems...
When I send byte[] to JS as a parameter of Invoke(), I dont get Array inside javascript function. Instead I have 'object' pixels, that is not looking as Array in firebug, but I can get values by calling pixels[10], for example.

Then, when I recieve data in MVC action, then is NULL. I dont where is the problem...while senind to JS, or while calling MVC action. Anybody knows?

Thanks
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900