1

It is a bit confusing to explain what I need, but I will try....

In the image below the browse button selects a file and the Upload button sends the file in a post method, but in some cases I need to process the file changing it to adapt for my importation, so I have created the "Convert file option".

enter image description here

The convert file option changes a file and sends it back to the user by downloading it again, then the user will import this file through my Upload button.

I need to get this FileContentResult not as a download, but sending this processed file through my other POST method and upload this automatically.

How can I get the File result and send it straight to my other POST?

I know that it is a completly weird behaviour, but I cannot change my Upload method as this redirects to another application which gets the post.

public FileContentResult ConvertFile()
{
    var file = Request.Files[0];
    if (file != null && file.ContentLength > 0)
    {
        /// my code... memorystream..etc..
        return new FileContentResult(memoryStream.ToArray(), "text/csv") { FileDownloadName = "abc.csv" };
    }
}
ekad
  • 14,436
  • 26
  • 44
  • 46
Roger Oliveira
  • 1,589
  • 1
  • 27
  • 55
  • 1
    Can't you extract some logic from the other POST and put it to another method, which can be used in `ConvertFile()` method? – kamil-mrzyglod Jun 15 '15 at 08:04
  • My other POST method, is redirecting to another application, I don't have access to its code, the only thing I have is the submit button and the URL of the other method. For instance: url../otherapplication/uploadfile – Roger Oliveira Jun 16 '15 at 01:58
  • 1
    'Posting from POST' is generally problematic. You can check following link for ideas http://stackoverflow.com/questions/4088625/net-simplest-way-to-send-post-with-data-and-read-response, http://stackoverflow.com/questions/4015324/http-request-with-post – kamil-mrzyglod Jun 16 '15 at 06:25

1 Answers1

0

See this post Hope this will help you.

Also, see the MSDN sample Click here

You can also use the third party libraries to deal with these problems like Restsharp etc., show some efforts.

Community
  • 1
  • 1
Learner
  • 776
  • 6
  • 14
  • 40