Click here to Skip to main content
15,896,201 members
Articles / Web Development / HTML

Atlas Tutorial: Creating an AJAX Scribble Application

Rate me:
Please Sign up or sign in to vote.
4.86/5 (56 votes)
5 Feb 2006CPOL14 min read 453K   1.5K   278  
A tutorial on creating an AJAX version of the popular MFC sample. The tutorial utilizes ASP.NET Atlas framework.
<%@ WebHandler Language="VB" Class="ScribbleImage" %>

Imports System
Imports System.Web
Imports System.Drawing
Imports System.Drawing.Imaging
Imports System.IO

Public Class ScribbleImage : Implements IHttpHandler, System.Web.SessionState.IRequiresSessionState
    
    Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
        context.Response.ContentType = "image/png"
        context.Response.Cache.SetNoStore()
        context.Response.Cache.SetCacheability(HttpCacheability.NoCache)
        context.Response.Cache.SetExpires(DateTime.Now)
        context.Response.Cache.SetValidUntilExpires(False)
        Dim bmp As Bitmap = CType(context.Session.Item("Image"), Bitmap)

        SyncLock (bmp)
            Using ms As MemoryStream = New MemoryStream()
                bmp.Save(ms, ImageFormat.Png)
                ms.Flush()
                context.Response.BinaryWrite(ms.GetBuffer())
            End Using
        End SyncLock
    End Sub
 
    Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
        Get
            Return False
        End Get
    End Property

End Class

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions