8
I have an Asp.Net MVC project where I have an image in memory and would like to download it.
See an excerpt from the code:
Image imagem = default(Image);
using (Bitmap b = new Bitmap(bitmapWidth, bitmapHeight))
{
using (Graphics g = Graphics.FromImage(b))
{
g.Clear(Color.Red);
var font = new Font("Arial", 50, FontStyle.Bold);
g.DrawString("Stackoverflow", font, Brushes.White, posicaoX, posicaoY);
}
using (MemoryStream stream = new MemoryStream())
{
b.Save(stream, ImageFormat.Jpeg);
imagem = Image.FromStream(stream);
}
}
using (System.Net.WebClient client = new System.Net.WebClient())
{
client.DownloadFile(imagem); // Não sei bem como posso fazer o Download.
}
Create an action to download.... which version of MVC?
– PauloHDSousa
What do you mean by "download"? The download should be done on another server. It would bring from elsewhere to here. Would you want to save on the server? Write to another server? That is to say, fzer upload? Want to use somewhere?
– Maniero
This code is running on a server, just wanted to download the file to the client. That’s exactly what is being done in the answer. :)
– Jedaias Rodrigues