When we talk about Classic ASP, the first thing that comes to mind is usually VBScript. It’s a great, straightforward language, but let's be honest: in the modern web ecosystem, everything talks JSON. And generating JSON manually by concatenating strings in VBScript is a nightmare no developer should have to endure today.
But here is a forgotten fact: Classic ASP on Windows always supported JScript.
With AxonASP (https://github.com/guimaraeslucas/axonasp), a GoLang-based server that runs Classic ASP natively on Linux, macOS, and Windows — this capability isn't just preserved; it becomes a powerful tool. AxonASP implements an ECMAScript 5.0 (ES5) engine, allowing you to write server-side JavaScript seamlessly integrated with your ASP pages.
The Best of Both Worlds
By using JavaScript as your primary language in an ASP page, you can naturally mix HTML content with server-rendered JS. More importantly, it completely eliminates the friction of building APIs. You get the native syntax of JavaScript (including built-in JSON.stringify and JSON.parse) combined with the robust, battle-tested standard ASP objects like Response, Request, and Server.
Add to this ecosystem libraries like G3DB, which makes connecting to and querying multiple databases simultaneously a breeze, and you suddenly have a highly capable, extremely lightweight backend stack running directly on a Linux server or inside a Docker container.
Real-World Example: A Micro-API Endpoint
To show you how this looks in practice, let's build a simple, secure API endpoint.
Imagine you need to serve data to a modern Vue.js or React frontend. Instead of setting up a heavy framework, you can drop this .asp file into your AxonASP www folder. It reads a query parameter, queries a database using G3DB, formats the result as JSON, and serves it with the correct HTTP headers.
<%@ Language="JavaScript" %>
<%
// 1. Setup modern HTTP headers for our API
Response.ContentType = "application/json";
Response.Charset = "UTF-8";
Response.AddHeader("Access-Control-Allow-Origin", "*");
// 2. Define our data retrieval logic
function getRecordData(recordId) {
// Instantiate the library with the primary ProgID.
var db = Server.CreateObject("G3DB");
// Opens using configuration/env values.
// Returns True on successful open from config/env; False otherwise.
var isConnected = db.OpenFromEnv("mysql");
if (!isConnected) {
// Returns the current error string.
throw new Error("Database connection failed: " + db.GetError());
}
// Use parameterized queries to ensure security against SQL Injection
var sql = "SELECT id, status, created_at, assigned_user FROM workflow_queue WHERE id = ?";
// Executes a query and returns a forward-only result set.
// Placeholder rewriting converts ? markers to the active driver format when needed.
var rs = db.Query(sql, recordId);
var result = null;
// Check if the result set is valid (G3DB returns Empty on failure).
if (rs != null) {
if (!rs.EOF) {
// Map the Recordset directly into a native JavaScript Object
result = {
id: String(rs("id")),
status: String(rs("status")),
createdAt: String(rs("created_at")),
assignedTo: String(rs("assigned_user"))
};
}
// Always clean up the Recordset
rs.Close();
} else {
// Capture execution failures using the read-only LastError property.
throw new Error("Query execution failed: " + db.LastError);
}
// Closes the current database pool managed by the G3DB object.
db.Close();
return result;
}
// 3. Process the incoming request
try {
// Extract the ID from the URL (e.g., api.asp?id=1042)
var reqId = String(Request.QueryString("id"));
if (reqId === "undefined" || reqId === "") {
Response.Status = "400 Bad Request";
Response.Write(JSON.stringify({
success: false,
error: "Missing required parameter: id."
}));
} else {
var record = getRecordData(reqId);
if (record) {
// Success: output standard JSON using native ES5 stringify
Response.Write(JSON.stringify({
success: true,
data: record
}));
} else {
Response.Status = "404 Not Found";
Response.Write(JSON.stringify({
success: false,
error: "Record not found in the database."
}));
}
}
} catch (e) {
// Global error handler
Response.Status = "500 Internal Server Error";
Response.Write(JSON.stringify({
success: false,
error: e.message
}));
}
%>
Why This Matters
Look at the code above. It is valid JavaScript, it runs incredibly fast, and it does exactly what it needs to do without layers of middleware or complex routing configurations.
Because AxonASP is built on GoLang, this entire environment is completely decoupled from Windows Server. You can write your legacy or new ASP systems using the syntax you already know, leverage standard ASP objects, query your databases with G3DB, and deploy it all on a minimal Linux distribution.
If you are maintaining Classic ASP applications, migrating them doesn't have to mean rewriting them from scratch in another language. You can modernize the infrastructure, switch to JavaScript where it makes sense (like API endpoints), and keep your systems running smoothly for the next decade.
Top comments (0)