蓝色天空.知识 · 实践 · 创造
我的收藏
在线代码实验室

离线校验经典 ASP 与 ASP.NET 编译管道、四类扩展名路由及工具演进

PYTHONWindows x64、CPython 3.12.14 离线 ASP.NET WebPages / Razor 语义验证器(本机未启动 IIS / IIS Express / WebMatrix 宿主环境)。explore-aspnet.py
explore-aspnet.py130 行
"""Offline ASP.NET semantic verification lab for Chapter 02 (aspnet)."""
import json

VERSION = "CPython 3.12.14 offline ASP.NET WebPages/Core semantic verifier (IIS/WebMatrix absent)"


def case_classic_asp_vs_aspnet_pipeline():
    classic_asp = {
        "released_year": 1998,
        "extension": ".asp",
        "default_script": "VBScript",
        "execution_mode": "interpreted",
        "compatible_with_aspnet": False,
    }
    aspnet = {
        "extension": ".aspx",
        "languages": ["C#", "VB.NET"],
        "execution_mode": "compiled",
        "response_format": "plain HTML",
        "integrated_auth": True,
    }
    pipeline_steps = ["browser_request", "engine_read", "compile_script", "execute_script", "return_html"]
    expected = {
        "classic_year": 1998,
        "classic_ext": ".asp",
        "aspnet_compiled": True,
        "pipeline_length": 5,
        "final_output": "return_html",
    }
    actual = {
        "classic_year": classic_asp["released_year"],
        "classic_ext": classic_asp["extension"],
        "aspnet_compiled": aspnet["execution_mode"] == "compiled",
        "pipeline_length": len(pipeline_steps),
        "final_output": pipeline_steps[-1],
    }
    return {
        "name": "classic_asp_vs_aspnet_pipeline",
        "summary": "对比经典 ASP(1998 解释执行 .asp)与 ASP.NET 编译执行管道及最终向浏览器返回纯 HTML 的机制",
        "expected": expected,
        "actual": actual,
        "passed": actual == expected,
    }


def case_file_extension_routing_map():
    ext_map = {
        ".asp": ("Classic ASP", "VBScript"),
        ".aspx": ("ASP.NET Web Forms", "C# / VB.NET"),
        ".cshtml": ("ASP.NET Razor C#", "C#"),
        ".vbhtml": ("ASP.NET Razor VB", "VB.NET"),
    }
    test_files = ["legacy.asp", "Default.aspx", "Index.cshtml", "Home.vbhtml"]
    resolved = {f: ext_map["." + f.rsplit(".", 1)[1]][0] for f in test_files}
    expected = {
        "legacy.asp": "Classic ASP",
        "Default.aspx": "ASP.NET Web Forms",
        "Index.cshtml": "ASP.NET Razor C#",
        "Home.vbhtml": "ASP.NET Razor VB",
    }
    return {
        "name": "file_extension_routing_map",
        "summary": "校验 .asp、.aspx、.cshtml 与 .vbhtml 四类扩展名到对应服务器端引擎与编程语言的映射",
        "expected": expected,
        "actual": resolved,
        "passed": resolved == expected,
    }


def case_dev_tools_and_modern_migration():
    historical_tools = {
        "WebMatrix": "Web Pages",
        "Visual Web Developer": "MVC / Web Forms",
        "Visual Studio": "All ASP.NET workloads",
    }
    modern_tools = ["Visual Studio 2022", "Visual Studio Code + C# Dev Kit", ".NET SDK CLI"]
    expected = {
        "historical_count": 3,
        "webmatrix_target": "Web Pages",
        "vwd_target": "MVC / Web Forms",
        "modern_count": 3,
    }
    actual = {
        "historical_count": len(historical_tools),
        "webmatrix_target": historical_tools["WebMatrix"],
        "vwd_target": historical_tools["Visual Web Developer"],
        "modern_count": len(modern_tools),
    }
    return {
        "name": "dev_tools_and_modern_migration",
        "summary": "核对历史开发工具(WebMatrix、Visual Web Developer、Visual Studio)定位及现代跨平台 .NET 工具替代",
        "expected": expected,
        "actual": actual,
        "passed": actual == expected,
    }


def case_razor_server_tech_trio():
    server_technologies = [
        ("Web Pages", "Razor"),
        ("MVC", "Model-View-Controller"),
        ("Web Forms", "Event-Driven"),
    ]
    expected = {"count": 3, "razor_backed": ["Web Pages", "MVC"]}
    actual = {
        "count": len(server_technologies),
        "razor_backed": ["Web Pages", "MVC"],
    }
    return {
        "name": "razor_server_tech_trio",
        "summary": "校验 ASP.NET 三大服务器端技术分支以及 Razor 标记语法在 Web Pages 与 MVC 中的共通角色",
        "expected": expected,
        "actual": actual,
        "passed": actual == expected,
    }


def main():
    cases = [
        case_classic_asp_vs_aspnet_pipeline(),
        case_file_extension_routing_map(),
        case_dev_tools_and_modern_migration(),
        case_razor_server_tech_trio(),
    ]
    print(json.dumps({"version": VERSION, "cases": cases}, ensure_ascii=False, indent=2))


if __name__ == "__main__":
    main()
本例需在 Windows x64、CPython 3.12.14 离线 ASP.NET WebPages / Razor 语义验证器(本机未启动 IIS / IIS Express / WebMatrix 宿主环境)。 中运行,请复制源码、保存文件或下载工程包后在本地执行验证。
运行说明与环境独立工程

运行环境:Windows x64、CPython 3.12.14 离线 ASP.NET WebPages / Razor 语义验证器(本机未启动 IIS / IIS Express / WebMatrix 宿主环境)。

入口文件:projects/web-forms-aspnet-lab/explore-aspnet.py

本地运行步骤快速上手
  1. 点击上方“保存源码”保存为 explore-aspnet.py,或下载右侧课程工程包。
  2. 确认本地已准备 Windows x64、CPython 3.12.14 离线 ASP.NET WebPages / Razor 语义验证器(本机未启动 IIS / IIS Express / WebMatrix 宿主环境)。。
  3. 按对应章节命令执行,结合正文核对实际输出。
附件与关联工程包下载

下载课程关联工程包:Web Forms

课程关联工程包(登记关联55章) · 含当前章节或实例 · mbskycom202612a2981.zip

下载课程关联工程包:Web Forms

课程关联工程包(登记关联1章) · 含当前章节或实例 · mbskycom202612a2960.zip
SITE SEARCH

搜索教程、工具与资讯

热门搜索

JavaScriptJSON格式化正则表达式AI 编程AI 翻译AI导航专题标签
Esc 关闭

欢迎登录蓝色天空网

使用会员账号,继续你的学习