Click here to Skip to main content
15,886,873 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi , i have a MVC Controller for handling calls and a silver light client
At Silver Light client i am using WebClient's OpenWriteAsync method to upload a file
At Controller a have a methood which saves the file and returns some json string but how do i get that returned value.


@ Client :
C#
Public void Somethod {
  Uri luri = new Uri(fileUploadSvcBaseUri);
  client.OpenWriteCompleted += client_OpenWriteCompleted;
  client.OpenWriteAsync(luri, "POST", fileStream);
}

void client_OpenWriteCompleted(object sender, OpenWriteCompletedEventArgs e)
        {
            try
            {
                if (e.Cancelled || e.Error != null)
                {
                    return;
                }
                var data = e.UserState as Stream;
                data.CopyTo(e.Result);
            }
            finally
            {
                ((WebClient)sender).OpenWriteCompleted -= client_OpenWriteCompleted;
                e.Result.Close();

            }
        }


@Controller:
C#
Public ActionResult CallingMethod()
{

 //// file save logic
return Json(path @ which File is saved );

}

how do i get this json string @ client_OpenWriteCompleted
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