Network Analyst routing
ArcGIS_Routing_CSharp\GenerateImage.aspx.cs
// Copyright 2011 ESRI
// 
// All rights reserved under the copyright laws of the United States
// and applicable international laws, treaties, and conventions.
// 
// You may freely redistribute and use this sample code, with or
// without modification, provided you include the original copyright
// notice and use restrictions.
// 
// See the use restrictions.
// 



using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using ESRI.ArcGIS.ADF.Web;
using System.Drawing;
using System.IO;

public partial class GenerateImage : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        MimeData md = (MimeData)Session["mymimedata"];
        ESRI.ArcGIS.ADF.Web.MapImage mi = new ESRI.ArcGIS.ADF.Web.MapImage(md);
        Bitmap bmp = mi.GetImage();

        Response.ContentType = "image/png";
        using (MemoryStream stream = new MemoryStream())
        {
            bmp.Save(stream, System.Drawing.Imaging.ImageFormat.Png);        
            stream.WriteTo(Response.OutputStream);
        }        
        bmp.Dispose();        
    }
}