set the mime type : Mime type « Page Lifecycle « ASP.NET Tutorial






<%@ Page language="c#" %>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Imaging" %>
<%@ Import Namespace="System.Drawing.Drawing2D" %>
<%@ Import Namespace="System.Drawing.Text" %>
<script runat="server">

    private void Page_Load(object sender, System.EventArgs e)
    {
      Bitmap OutputBitmap = new Bitmap(320,200);
      Graphics DrawGraphic = Graphics.FromImage(OutputBitmap);

      DrawGraphic.Clear(Color.Beige);
      
      DrawGraphic.SmoothingMode = SmoothingMode.AntiAlias;
      DrawGraphic.TextRenderingHint = TextRenderingHint.AntiAlias;

      String MessageString = System.DateTime.Now.ToString();

      DrawGraphic.DrawString(MessageString, 
        new Font("arial",18,FontStyle.Bold),
        Brushes.DarkBlue, new PointF(20,20));

      Response.Clear();
      Response.ContentType="image/jpeg";

      OutputBitmap.Save(Response.OutputStream, ImageFormat.Jpeg);

      OutputBitmap.Dispose();
      DrawGraphic.Dispose();
    }

</script>








5.15.Mime type
5.15.1.set the mime type
5.15.2.JPeg image
5.15.3.Gif image