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
  • 7,488
  • 4
  • 34
  • 53
batwadi
  • 1,785
  • 5
  • 26
  • 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,450
  • 9
  • 55
  • 111
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,061
  • 3
  • 37
  • 44