1

I have to show runtime generated image on a View in ASP.NET MVC web application. How can I render this image - should I use an .aspx or .ashx file?

Frank Bryce
  • 8,076
  • 4
  • 38
  • 56
batwadi
  • 1,836
  • 7
  • 29
  • 42
  • You've got a full answer here: http://stackoverflow.com/questions/186062/can-an-asp-net-mvc-controller-return-an-image –  Dec 31 '09 at 16:18
  • Also, I'd suggest not using the file system as an intermediary; pick one of the solutions that returns a stream and just send the backing stream that contains your image down the wire. –  Dec 31 '09 at 16:20

2 Answers2

0

create a bitmap object

create a graphic object based on the bitmap

use the drawstring function from the graphic object

when your done, read this

Community
  • 1
  • 1
Fredou
  • 19,848
  • 10
  • 58
  • 113
0

If you choose between aspx and ashx - ashx is the better because they are lighter. In ASP.NET MVC you can also create your own ImageResult and use Controller's action to render images. You can use GDI++ to generate the images. If you need transparent images I suggest you save all images as .png files because the quallity of GDI++ generated .png-s is better than any other format.

Branislav Abadjimarinov
  • 5,101
  • 3
  • 35
  • 44