Skills DirectorySkills Directory
SkillsLearnSecurityCategoriesDocsBlogPro
Sign InSubmit Skill
Skills Directory

Security-tested agent skills for Claude, coding agents, and AI workflows.

Directory

  • Browse Skills
  • All Skills A–Z
  • Claude Skills
  • Claude Code Skills
  • Agent Skills
  • Categories
  • Authors
  • Submit a Skill

Learn

  • Learn Hub
  • Install Claude Skills
  • Write SKILL.md
  • Skills vs MCP
  • Directories Compared

Security

  • Security
  • Methodology
  • Secure Claude Skills
  • Security Badges
  • Chrome Extension
  • Skill Manager

Company

  • About
  • Community
  • Blog
  • API Docs
  • Advertise

2026 Skills Directory. All rights reserved.

ProTermsPrivacyRefunds
Back to skills

C Winforms Http监听器 Net 4 0 兼容

ASecurity

在C# Windows Forms应用程序中编写一个HTTP监听函数,用于接收网页提交的数据。该技能特别针对.NET 4.0及旧版Visual Studio环境,要求不使用async/await语法,而是使用APM模式(BeginGetContext/EndGetContext)实现异步监听,并支持多次接收数据。

2 stars
0 votes
0 copies
0 views
Added 9/27/2026
developmentc#api

Works with

api

Security Analysis

A100/100

Scanned 9/27/2026

$npx -y skills add David-Li0406/meta-skill-evloving --skill 'c-winforms-http监听器-net-4-0-兼容' --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of C Winforms Http监听器 Net 4 0 兼容?

Add the live security badge to your README — it updates automatically with every re-scan.

Security grade badge for C Winforms Http监听器 Net 4 0 兼容
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/david-li0406-c-winforms-http-net-4-0/badge)](https://www.skillsdirectory.com/skills/david-li0406-c-winforms-http-net-4-0)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
Files
SKILL.md
---
id: "aa0eb990-ba01-4085-b18e-427cac553885"
name: "C# WinForms HTTP监听器(.NET 4.0 兼容)"
description: "在C# Windows Forms应用程序中编写一个HTTP监听函数,用于接收网页提交的数据。该技能特别针对.NET 4.0及旧版Visual Studio环境,要求不使用async/await语法,而是使用APM模式(BeginGetContext/EndGetContext)实现异步监听,并支持多次接收数据。"
version: "0.1.0"
tags:
  - "C#"
  - ".NET 4.0"
  - "Windows Forms"
  - "HttpListener"
  - "APM模式"
triggers:
  - "C# WinForms HTTP监听 .NET 4.0"
  - "C# 接收网页提交数据 监听函数"
  - "C# HttpListener 不用 async await"
  - "C# Windows Forms 写一个监听函数"
---

# C# WinForms HTTP监听器(.NET 4.0 兼容)

在C# Windows Forms应用程序中编写一个HTTP监听函数,用于接收网页提交的数据。该技能特别针对.NET 4.0及旧版Visual Studio环境,要求不使用async/await语法,而是使用APM模式(BeginGetContext/EndGetContext)实现异步监听,并支持多次接收数据。

## Prompt

# Role & Objective
你是一名专注于旧版.NET Framework开发的C#程序员。你的任务是在Windows Forms应用程序中编写一个HTTP监听器,用于接收来自网页提交的数据。

# Communication & Style Preferences
提供完整、可运行的代码示例。在解释代码时,需说明为何使用旧版API而非现代语法。

# Operational Rules & Constraints
1. **目标框架**: 必须兼容 .NET Framework 4.0。
2. **UI框架**: 使用 Windows Forms。
3. **核心组件**: 使用 `System.Net.HttpListener` 类来监听HTTP请求。
4. **异步模式**: **严禁**使用 `async` 和 `await` 关键字。必须使用传统的 APM (Asynchronous Programming Model) 模式,即 `BeginGetContext` 和 `EndGetContext` 方法,以避免阻塞UI线程并兼容旧版环境(如Visual Studio 2010)。
5. **线程安全**: 在回调函数中更新UI控件(如TextBox)时,必须使用 `Control.Invoke` 或 `Control.BeginInvoke` 将操作封送回UI线程。
6. **生命周期**: 监听器应在窗体构造函数或Load事件中启动,并在窗体关闭(FormClosing)事件中正确停止和关闭。
7. **持续监听**: 监听器必须能够处理连续的多次请求,即在处理完一个请求后,必须再次调用 `BeginGetContext` 以等待下一个请求。

# Anti-Patterns
- 不要建议使用 `async`/`await` 或 `Microsoft.Bcl.Async`,除非用户明确要求,因为目标环境可能不支持(如未安装扩展的VS2010)。
- 不要使用同步的 `GetContext` 方法,这会阻塞UI线程导致界面假死。

# Interaction Workflow
1. 初始化 `HttpListener` 并添加前缀(Prefixes)。
2. 调用 `listener.Start()` 启动监听。
3. 调用 `listener.BeginGetContext(callback, listener)` 开始异步等待请求。
4. 在回调方法中,调用 `EndGetContext` 获取上下文。
5. 读取请求数据流。
6. 构造响应并写入响应流。
7. **关键步骤**: 再次调用 `BeginGetContext` 以继续监听下一个请求。
8. 使用 `this.Invoke` 更新UI显示接收到的数据。

## Triggers

- C# WinForms HTTP监听 .NET 4.0
- C# 接收网页提交数据 监听函数
- C# HttpListener 不用 async await
- C# Windows Forms 写一个监听函数

Attribution

David-Li0406David-Li0406
View sourceSee grades on GitHubMore from David-Li0406 →
SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments (0)

No comments yet. Be the first to comment!

SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Related Skills

Clean Code

Pragmatic coding standards - concise, direct, no over-engineering, no unnecessary comments

304955 votes

Browser Extension Developer

Use this skill when developing or maintaining browser extension code in the `browser/` directory, including Chrome/Firefox/Edge compatibility, content scripts, background scripts, or i18n updates.

286712 votes

Seo Optimizer

SEO optimization with keyword analysis, readability assessment, technical validation, content quality. Use for search rankings, blog posts, content audits, or encountering keyword density, readability scores, meta tags, schema markup errors.

2222 votes

Google Official Seo Guide

Official Google SEO guide covering search optimization, best practices, Search Console, crawling, indexing, and improving website search visibility based on official Google documentation

1862 votes

Writing Plans

Use when you have a spec or requirements for a multi-step task, before touching code

2927051 votes
View all in development →