Click here to Skip to main content
13,795,369 members
Click here to Skip to main content
Add your own
alternative version


91 bookmarked
Posted 7 Jul 2003

ASP Web Server

, 7 Jul 2003
Rate this:
Please Sign up or sign in to vote.
This article presents a Web server with ASP support.


This article presents a mini Web server with ASP support. When writing these classes I was inspired by an article from MSDN Magazine 'A Client-side Environment for ASP Pages ' by Dino Esposito. Although I didn't use any of the code from this MSDN article (mainly because it was written in VB) it was very helpful to get me started. One problem of Dino's solution is, that it is using the msscript.ocx (Microsoft Script Control), which is not available on all Windows system (you must download and install it separately from Internet Explorer). So in this article I present you a MFC solution that uses the Microsoft Scripting Engine COM interface.


  • Multi threaded.
  • Real time server log.
  • Configure directory for web pages (same for all connections).
  • Configure default HTML page.
  • Support for GET, POST and HEAD methods.
  • Sends directory listing if default HTML is not found in directory.
  • Basic error handling (no custom messages yet).
  • ASP support (Request, Response, Server and Form collections)
  • Cookie support (including 'arrays' and enumeration!)
  • SSI (Server Side Includes) support

Known limitations

  • Most collections are case sensitive unlike real ASP collections!!!
  • Form and QueryString collections do not support arrays at this moment -> no list/combobox support
  • Application object not implemented
  • Session collection is not included. (but is available from my website).

Major classes used


This is a wrapper class around the COM interface of Microsoft's Scripting Engine. It simply converts all calls to the COM interface to easy to use MFC functions.


This class implements the ASP parser. It attaches the interfaces to the script engine and prepares the ASP page for execution. First all HTML code is converted to ASP code (Response.Write lines), so the resulting page contains only ASP code (= vbscript code). The Script Engine then executes this code and all output is written to the Response buffer. Any calls to Response or Request objects will be routed to my CResponseObject and CRequestObject classes. In the case of a web server this response buffer will be send back to the web browser.


This class provides the IResponse interface to the scripting engine. The IReponse is used by ASP to write data from a script to the output HTML page. Only the most common used properties and methods are implemented.


This class provides the IRequest interface to the scripting engine. The IRequest is used by ASP to read data from various collections into the script. The following collections are (partly) implemented:
  • QueryString Collection: used to get URL parameters.
  • Form Collection : used to get Form variables.
  • Server Variables Collection: used to get server information (local or remote ip address, server name and much more).
  • Cookies Collection: used to get data from cookies.

CCookie and CCookieEnum

Implementation of the ICookie interface to support cookies. This code is partly based the ATL class CCookie from Microsoft VC++ 7.0.

CCookieCollection and CCookieCollectionEnum

This is an attempt to duplicate the behaviour of the ASP IRequestDictionary interface to support cookies.


This socket accepts all incoming connections. When a client connects to the server, CListenSocket accepts the connection and creates a new thread (CClientThread) that will take care of all further communication between the client and the server. After the thread has been created, CListenSocket will return to its waiting state.


This thread will handle all communication between the client and the server using CControlSocket.


This socket class will process all incoming request and send back the response (files) to the client. All the other classes are just UI related.

Contacting the Author

Please send any comments or bug reports to me via email. For updates to this article (and many other articles), check my site:

Revision history

  • July 4, 2004 - Initial revision.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Pablo van der Meer
Web Developer
Netherlands Netherlands
No Biography provided

You may also be interested in...

Comments and Discussions

Generalreading cookies in vc++ Pin
Dhiraj kumar Saini30-Sep-07 21:03
memberDhiraj kumar Saini30-Sep-07 21:03 
GeneralDownload file Pin
trinh van hung2-Nov-06 20:47
membertrinh van hung2-Nov-06 20:47 
Jokegood , but exist one problem! Pin
Johnson88813-Feb-06 22:41
memberJohnson88813-Feb-06 22:41 
GeneralRe: good , but exist one problem! Pin
Pablo van der Meer13-Feb-06 22:59
memberPablo van der Meer13-Feb-06 22:59 
GeneralExquisite code and article ! Sweet Pin
Dan Clark24-Jan-06 10:11
memberDan Clark24-Jan-06 10:11 
GeneralCompilation error Pin
drjoju17-Aug-05 7:15
memberdrjoju17-Aug-05 7:15 
GeneralRe: Compilation error Pin
Racuca7-Mar-11 16:13
memberRacuca7-Mar-11 16:13 
QuestionCan we download webpages from URL containing https in any language. Pin
skyt9-Jun-04 0:49
memberskyt9-Jun-04 0:49 
GeneralRequest Object is not BinaryRead method Pin
handong4-Feb-04 21:24
memberhandong4-Feb-04 21:24 
GeneralRe: Request Object is not BinaryRead method Pin
Pablo van der Meer4-Feb-04 21:34
memberPablo van der Meer4-Feb-04 21:34 
QuestionQueryString bug? Pin
Eugene Lin4-Jan-04 13:18
memberEugene Lin4-Jan-04 13:18 
AnswerRe: QueryString bug? Pin
Pablo van der Meer4-Jan-04 22:45
memberPablo van der Meer4-Jan-04 22:45 
GeneralRe: QueryString bug? Pin
Eugene Lin5-Jan-04 7:13
memberEugene Lin5-Jan-04 7:13 
Generalstatic link Pin
macrogu29-Oct-03 21:55
membermacrogu29-Oct-03 21:55 
GeneralRe: static link Pin
Pablo van der Meer29-Oct-03 22:15
memberPablo van der Meer29-Oct-03 22:15 
GeneralThe Best!!!! Pin
Georgi Petrov17-Oct-03 0:13
memberGeorgi Petrov17-Oct-03 0:13 
GeneralSUPERMEN! Pin
Nikolai Teofilov14-Sep-03 22:16
memberNikolai Teofilov14-Sep-03 22:16 
Generalsample: how to connect to "index.html" Pin
Ralph18-Aug-03 6:47
memberRalph18-Aug-03 6:47 
GeneralRe: sample: how to connect to "index.html" Pin
Abhishek Tiwari25-Apr-06 19:51
memberAbhishek Tiwari25-Apr-06 19:51 
GeneralRe: sample: how to connect to "index.html" Pin
Ralph25-Apr-06 22:02
memberRalph25-Apr-06 22:02 
GeneralAn Excellent article. Pin
Nebojsa Janjic26-Jul-03 23:56
memberNebojsa Janjic26-Jul-03 23:56 
GeneralRe: An Excellent article. Pin
Pablo van der Meer27-Jul-03 0:24
memberPablo van der Meer27-Jul-03 0:24 
GeneralMethod of connection Pin
Code4Food15-Jul-03 13:17
memberCode4Food15-Jul-03 13:17 
GeneralRe: Method of connection Pin
Pablo van der Meer16-Jul-03 4:53
memberPablo van der Meer16-Jul-03 4:53 
GeneralRe: Method of connection Pin
Code4Food16-Jul-03 5:07
memberCode4Food16-Jul-03 5:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web02 | 2.8.181207.3 | Last Updated 8 Jul 2003
Article Copyright 2003 by Pablo van der Meer
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid