Back to Weixinmpsdk

Readme.En

readme.en.md

2026.8.752.4 KB
Original Source

<!-- -->

Senparc.Weixin β€”β€” WeChat .NET SDK

[δΈ­ζ–‡]

πŸ“ˆ Senparc.Weixin SDK is currently the most widely used WeChat .NET SDK and one of the most popular .NET open-source projects in China. This project has been continuously maintained for over 12 years and has powered a large number of successful systems and applications. We will continue iterating, and are deeply integrating AI scenarios with more samples coming online. Welcome to join our community πŸ‘

With Senparc.Weixin, you can quickly build applications across the entire WeChat ecosystem, including Official Accounts, Mini Programs, Mini Games, Enterprise WeChat, Open Platform, WeChat Pay, JS-SDK, WeChat hardware/Bluetooth, and more. The samples in this repository are also suitable for .NET beginners.

Currently, Senparc.Weixin supports almost all WeChat modules and APIs, and supports multiple frameworks including .NET 3.5 / 4.0 / 4.5 / .NET Standard 2.x / .NET Core 2.x / .NET Core 3.x / .NET 6.0 / .NET 7.0 / .NET 8.0 / .NET 10.0. It is compatible with MVC, Razor, WebApi, Console, desktop apps (.exe), Blazor, MAUI, background services, and more, while remaining fully decoupled from external frameworks.

Since the project started in 2013, we have kept it continuously updated for over 12 years, and have shared complete source code and design ideas without reservation. We hope more developers can benefit from it, spread the open-source spirit, and help advance open source in China. Sincere thanks to everyone who has supported us along the way.

If you like this project and want us to continue improving it, please give us a β˜…Star :)

πŸ”” Announcement

[!TIP] πŸ₯‡ Senparc Developer Community 2025-2026 Contributor Ranking

⚑ .NET 10 stable is now released. Latest Sample for .NET 10 (backward compatible), online demo: https://sdk.weixin.senparc.com/

πŸ”₯ AI chatbot WeChat integration sample is now online! View

🎬 Scott Hanselman interview on AI topics Watch video

[!NOTE] πŸ”’ WeChat Pay V3 module (V1.0) is online! NuGet

🎠 Fully supports automatic long-text chunking and sending. More: Auto-replying Extra-long Messages for GenAI Applications

<!-- _1. In order to isolate the demo from the source code and make it easier for everyone to find the demo, the Senparc.Weixin.MP.Sample and other folders have been moved to the [/Samples/](/Samples/) folder._ _2. The `Senparc.Weixin.Plugins` plan has been launched, details [click here](https://github.com/JeffreySu/WeiXinMPSDK/tree/master/Plugins)._ -->

🌟 Start: Module-by-Module Docs + Runnable Samples

ModuleLink
Official Accounthttps://sdk.weixin.senparc.com/Docs/MP/
Mini Programhttps://sdk.weixin.senparc.com/Docs/WxOpen/
Enterprise WeChathttps://sdk.weixin.senparc.com/Docs/Work/
WeChat Pay V3 (recommended)https://sdk.weixin.senparc.com/Docs/TenPayV3/
WeChat Pay V2 (not recommended)https://sdk.weixin.senparc.com/Docs/TenPayV2/

[!NOTE]

  1. Each module page above includes both docs and immediately runnable code templates (you only need to fill WeChat settings, no code changes required).
  1. Configuration, registration, and API invocation patterns are consistent across modules. Learn one module and you can quickly apply the same approach to others.
  1. The /docs directory provides more complete guidance for advanced development, click here.
  1. Senparc.Weixin SDK modules are fully decoupled and independently published. To simplify dependencies, you can directly use Senparc.Weixin.All to reference all modules automatically.

πŸš€ Hello World: Start Your WeChat Development Journey in 3 Lines

[!NOTE]

  1. The sample source code below is in /Samples/MP/Senparc.Weixin.Sample.MP, using Official Account as an example. Once you know this flow, you can apply the same pattern to Mini Program, Enterprise WeChat, WeChat Pay, etc.
  1. For other module or integrated demos, see standalone samples under /Samples/ or integrated/advanced samples under /Samples/All/.

Startup code (only 2 lines):

  1. <strong>Add configuration above builder.Build() in Program.cs:</strong>
C#
builder.Services.AddSenparcWeixinServices(builder.Configuration);  

If you are using legacy Startup.cs, this line belongs in ConfigureServices().

  1. <strong>Enable configuration below builder.Build() in Program.cs:</strong>
C#
var registerService = app.UseSenparcWeixin(app.Environment, null, null, register => { },  
    (register, weixinSetting) =>  
{  
    // Register Official Account information (can be executed multiple times to register multiple Official Accounts)  
    register.RegisterMpAccount(weixinSetting, "Senparc Network Assistant Official Account");  
});  
  • If you are using legacy Startup.cs, this block belongs in Configure().
  • If you want auto-registration for all configured accounts, append autoRegisterAllPlatforms: true (requires Senparc.Weixin.All):
C#
var registerService = app.UseSenparcWeixin(app.Environment, null, null, register => { },
    (register, weixinSetting) => { /* no manual registration needed */ },
    autoRegisterAllPlatforms: true /* auto-register all platforms */
);

Call advanced APIs (only 1 line):

You can call APIs anywhere in your program (customer service API as an example):

C#
await CustomApi.SendTextAsync("AppId", "OpenId", "Hello World!");  

[!TIP]

  1. Senparc.Weixin SDK automatically manages AccessToken through the full lifecycle. During development, you only need AppId and do not need to handle token expiration manually.
  1. Registration information such as AppId can be automatically obtained from Senparc.Weixin.Config.SenparcWeixinSetting, and the relevant parameters are configured in appsettings.json.
  2. A synchronous version is also available: Senparc.Weixin.MP.AdvancedAPIs.CustomApi.SendText().
  1. Namespace and parameter naming follow official API documentation conventions as closely as possible (especially return fields), making code lookup and testing faster while reducing bug risks.

[!TIP] At this point, you can already apply the same pattern to all WeChat modules.

How to use Official Account messaging?

Official Accounts provide a built-in chat window for text, image, voice, and other interactions.

The same pattern also applies to Enterprise WeChat and Mini Program customer service messaging. Only two steps:

Step 1: Create a custom MessageHandler to control message processing logic:

<details> <summary>CustomMessageHandler.cs</summary>
C#
using Senparc.NeuChar.Entities;  
using Senparc.Weixin.MP.Entities;  
using Senparc.Weixin.MP.Entities.Request;  
using Senparc.Weixin.MP.MessageContexts;  
using Senparc.Weixin.MP.MessageHandlers;  
  
namespace Senparc.Weixin.Sample.MP  
{  
    /// <summary>  
    /// Custom MessageHandler  
    /// Inherits from MessageHandler and overrides the corresponding request handling methods  
    /// </summary>  
    public partial class CustomMessageHandler : MessageHandler<DefaultMpMessageContext>  
    {  
        public CustomMessageHandler(Stream inputStream, PostModel postModel, int maxRecordCount = 0,  
            bool onlyAllowEncryptMessage = false, IServiceProvider serviceProvider = null)  
            : base(inputStream, postModel, maxRecordCount, onlyAllowEncryptMessage, null, serviceProvider)  
        {  
        }  
  
        /// <summary>  
        /// Default message for all unhandled types  
        /// </summary>  
        /// <returns></returns>  
        public override IResponseMessageBase DefaultResponseMessage(IRequestMessageBase requestMessage)  
        {  
            //ResponseMessageText can also be News or other types  
            var responseMessage = this.CreateResponseMessage<ResponseMessageText>();  
            responseMessage.Content = $"You sent a message, but the program did not specify a processing procedure";  
            return responseMessage;  
        }  
  
        public override Task<IResponseMessageBase> OnImageRequestAsync(RequestMessageImage requestMessage)  
        {  
            //Handle image requests...  
        }  
  
        public override Task<IResponseMessageBase> OnLocationRequestAsync(RequestMessageLocation requestMessage)  
        {  
            //Handle location requests...  
        }  
    }  
}  
</details>

Step 2: Request the CustomMessageHandler:

We provide two ways to request the CustomMessageHandler: Middleware (recommended) and Controller (or WebApi). You can choose either one. Taking Middleware as an example, after enabling the configuration in Program.cs, add the following code to register the MessageHandler:

C#
app.UseMessageHandlerForMp("/WeixinAsync",  
    (stream, postModel, maxRecordCount, serviceProvider)  
        => new CustomMessageHandler(stream, postModel, maxRecordCount, false, serviceProvider),  
    options   
        =>  
    {  
        options.AccountSettingFunc = context => Senparc.Weixin.Config.SenparcWeixinSetting;  
    });  

At this point, you can use https://YourDomain/WeixinAsync to configure your WeChat Official Account backend in [Settings and Development] > [Basic Configuration] > [Server Address (URL)], and set the Token in appsettings.json (also applies to Enterprise WeChat and Mini Program; see the corresponding Samples).

In addition, you can also use the Controller (or WebApi) method to have more precise control over the entire message processing process (or use it in .NET Framework), click here to view.

Now you have mastered the basic skills required for WeChat platform development. Keep reading for more resources:

πŸ“‡ More Indexes

This repository includes source code for .NET Framework / .NET Standard 2.0+ / .NET Core 3.1 / .NET 6 / .NET 7 / .NET 8 / .NET 10 (same core logic):

🏹 Libraries by Module

#ModuleDLLNuGetSupported .NET
1Core librarySenparc.Weixin.dll
2Official Account /
JSSDK / Shake Around / etc.Senparc.Weixin.MP.dll
3[Mini Program
(incl. Mini Games)
(independent project)](https://github.com/JeffreySu/WxOpen)Senparc.Weixin.WxOpen.dll
4WeChat PaySenparc.Weixin.TenPay.dll
5WeChat Pay V3Senparc.Weixin.TenPayV3.dll
6ASP.NET MVC extensionSenparc.Weixin.MP.MVC.dll
7Enterprise Account
(officially discontinued)Senparc.Weixin.QY.dll
9Enterprise WeChatSenparc.Weixin.Work.dll
9WeChat Open PlatformSenparc.Weixin.Open.dll
10Redis distributed cacheSenparc.Weixin.Cache.
Redis.dll
11Memcached
distributed cacheSenparc.Weixin.Cache.
Memcached.dll
12[WebSocket
(independent project)](https://github.com/JeffreySu/Senparc.WebSocket)Senparc.WebSocket.dll
13All-in-One packageSenparc.Weixin.All.dll

Legend

.NET Framework 4.6.2+.NET Standard 2.0 / 2.1.NET 10.0, backward compatible with .NET 5.0-9.0

[!WARNING]

  1. Since May 1, 2019, .NET Framework 3.5 and 4.0 are no longer updated. The last stable version for .NET Framework 3.5 + 4.0 is available here.
  1. Since April 3, 2022, .NET Framework 4.5 has been upgraded to 4.6.2. The last stable version for .NET Framework 4.5 is available here.
  1. If you still use .NET Framework, we recommend upgrading to .NET Framework 4.8+ by January 12, 2027. Official support for .NET Framework 4.6.2 ends then (see details).
  1. Use Senparc.Weixin.All to reference all modules at once.

Feature Support

  • Most of the WeChat 8.x APIs are supported, including WeChat Pay, custom menu/personalized menu, template message interface, material upload interface, mass message interface, customer service interface, payment interface, WeChat store interface, card interface, invoice interface, etc.
  • Support for WeChat Official Accounts, Mini Programs, Enterprise Accounts, Open Platforms, WeChat Pay, and other modules.
  • Support for user session context (solving the problem of using Session to process user information on the server).
  • Full support for the latest APIs of WeChat Official Accounts, Mini Programs, Enterprise Accounts (WeChat Work), WeChat Pay V2/V3, and Open Platforms.
  • Support for distributed caching and caching strategy extension (default support: local cache, Redis, Memcached, can be freely extended), no need to worry about the type of cache used during development, can be freely switched in the configuration file or during runtime.
  1. The official APIs are perfectly integrated, and all upgrades will try to ensure backward compatibility unless otherwise specified. So you can safely use or directly upgrade (overwrite) the latest DLLs. It is recommended to use NuGet for updates.
  1. You can also modify and compile the code yourself. Open the Senparc.Weixin.Sample.Net8.sln solution to see all the source code. When the compilation mode is Release, a local NuGet package will be automatically generated (default generated in the /src/BuildOutPut/ folder).

πŸ’Ύ Explanation of Source Code Project Folders (under the src folder)

<details> <summary>Expand</summary>
FolderDescription
Senparc.WebSocketWebSocket module
Senparc.Weixin.CacheSenparc.Weixin.Cache.Memcached.dll, Senparc.Weixin.Cache.Redis.dll, and other distributed cache extension solutions
Senparc.Weixin.AspNetSenparc.Weixin.AspNet.dll, a class library specifically for web support
Senparc.Weixin.MP.MvcExtensionSenparc.Weixin.MP.MvcExtension.dll source code, an extension package for MVC projects
Senparc.Weixin.MPSenparc.Weixin.MP.dll WeChat Official Account SDK source code
Senparc.Weixin.MP.MiddlewareSenparc.Weixin.MP.Middleware.dll WeChat Official Account message middleware source code
Senparc.Weixin.OpenSenparc.Weixin.Open.dll Third-party Open Platform SDK source code
Senparc.Weixin.TenPaySenparc.Weixin.TenPay.dll & Senparc.Weixin.TenPayV3.dll source code for WeChat Pay V2 and V3
Senparc.Weixin.WorkSenparc.Weixin.Work.dll Enterprise WeChat SDK source code
Senparc.Weixin.Work.MiddlewareSenparc.Weixin.Work.Middleware.dll Enterprise WeChat message middleware source code
Senparc.Weixin.WxOpenSenparc.Weixin.WxOpen.dll WeChat Mini Program SDK source code, including Mini Games
Senparc.Weixin.WxOpen.MiddlewareSenparc.Weixin.WxOpen.Middleware.dll WeChat Mini Program message middleware source code, including Mini Games
Senparc.WeixinSource code for all Senparc.Weixin.[x].dll basic libraries
</details>

Enter Folder

πŸ–₯️ Explanation of Samples Folder (under the Samples folder)

The usage of all modules in the Senparc.Weixin SDK is highly consistent, including the configuration process, AccessToken management, message processing, service messages, API calls, etc. You only need to refer to the usage of any module (it is recommended to start with Official Accounts or Mini Programs), and you can apply the same principles to other modules.

From the following samples, you can learn about the configuration and usage of each independent module. Just open the .sln solution file in the corresponding folder to view the source code and run it to see the documentation. The All folder contains more comprehensive and advanced feature demonstrations.

FolderDescriptionSDK Reference Method
MPOfficial AccountsNuGet Package
TenPayV2WeChat Pay V1 and V2NuGet Package
TenPayV3WeChat Pay V3 (TenPay APIv3)NuGet Package
WorkEnterprise AccountsNuGet Package
WxOpenMini ProgramsNuGet Package
SharedShared files required by all samples
AllA mixed scenario demonstration that includes all functions of WeChat Official Accounts, Mini Programs, WeChat Pay, Enterprise Accounts, etc., recommended for projects that integrate multiple platforms or require deep development (advanced)
┣ All/consoleCommand Line Console Demo (.NET Core)NuGet Package
┣ All/net45-mvcDemo that can be directly published and used (.NET Framework 4.5 + ASP.NET MVC)NuGet Package
β”— All/net10-mvcDemo ready for production use (.NET 10.0), compatible with .NET 5.0, 6.0, 7.0, 8.0, and .NET Core<strong>Source Code (Latest)</strong>
β”— All/net8-mvcDemo ready for production use (.NET 8.0), compatible with .NET 5.0, 6.0, 7.0, and .NET Core<strong>Source Code (Latest)</strong>

Enter Samples Folder

<!-- ## Customize Your WeChat Project Sample Web version: [Click here](https://www.cnblogs.com/szw/p/WeChatSampleBuilder-V2.html#Web-WeChatSampleBuilder) for the tutorial. --> <!-- 2. Desktop version: Log in to [https://weixin.senparc.com/User](https://weixin.senparc.com/User) to download the WeChatSampleBuilder tool and view the instructions. --> <!-- > Note: Using the WeChatSampleBuilder tool is only for simplifying the sample code for testing and learning purposes. It cannot help you generate complete production projects with business logic. To build a production project, please refer to the complete demos or other tutorials. It is recommended to use existing system frameworks for project construction, such as [NeuCharFramework](https://github.com/NeuCharFramework/NCF). -->

🎨 Resources

  1. Official website: https://weixin.senparc.com/
  2. Online demo (for .NET 10.0, backward compatible with .NET 6.0, 7.0, 8.0, and .NET Core): https://sdk.weixin.senparc.com/
  3. WeChat development tutorials: https://www.cnblogs.com/szw/p/weixin-course-index.html
  4. WeChat technical community: https://weixin.senparc.com/QA
  5. Custom menu online editor: https://sdk.weixin.senparc.com/Menu
  6. Online message testing tool: https://sdk.weixin.senparc.com/SimulateTool
  7. Cache testing tool: https://sdk.weixin.senparc.com/Cache/Test
  8. chm help document download: https://sdk.weixin.senparc.com/Document
  9. Source code and latest updates: https://github.com/JeffreySu/WeiXinMPSDK
  10. WeChat development resource collection: https://github.com/JeffreySu/WeixinResource
  11. Auxiliary system for reading "In-depth Analysis of WeChat Development": https://book.weixin.senparc.com
  12. Purchase "In-depth Analysis of WeChat Development": https://item.jd.com/12220004.html
  13. "Rapid Development of WeChat Official Accounts and Mini Programs" video tutorial: https://github.com/JeffreySu/WechatVideoCourse
  • Technical communication QQ groups:

Group 1 (Official Accounts): 300313885

Group 14 (Video Course Students): 588231256

Group 10 (Distributed Cache): 246860933

Group 12 (Mini Programs): 108830388

Group 16 (Open Platform): 860626938

The following groups are full:

Group 2: 293958349 (Full), Group 3: 342319110 (Full)

Group 4: 372212092 (Full), Group 5: 377815480 (Full), Group 6: 425898825 (Full)

Group 7: 482942254 (Full), Group 8: 106230270 (Full), Group 9: 539061281 (Full)

Group 11: 553198593 (Full), Group 13: 183424136 (Open Platform, Full), Group 15: 289181996 (Full)

  • Business contact QQ: 498977166
<!-- * Sina Weibo: [@θ‹ιœ‡ε·](http://weibo.com/jeffreysu1984) -->

If this project is helpful to you, we welcome any form of donation or participation in code updates and feedback. Thank you!

Donation: Enter

πŸ“– Senparc Official Book Tutorial

The WeChat development book, titled "In-Depth Analysis of WeChat Development: Efficient Development Secrets for Official Accounts and Mini Programs," completed by Jeffrey Su and the Senparc team after 2 years of effort, has been published. The book comes with an auxiliary reading system: BookHelper.

Welcome to purchase the genuine book: 【Buy Genuine】

The code snapshot of the book's publication version is in the branch BookVersion1.

πŸ’» Senparc Official Video Tutorial

In order to help everyone understand WeChat development details more intuitively and learn practical techniques in .NET development, we established the "Senparc Classroom" group and launched WeChat development video courses, covering the following two parts:

  1. WeChat development fundamentals
  1. Case study of official accounts and mini programs

The total course duration is 60 lessons, with additional episodes.

Currently, the videos are available on NetEase Cloud Classroom, with well-produced content and abundant materials. The course has been selected as an "A" level course. 【Watch Videos】, 【View Course Code and Slides】.

πŸ§ͺ Follow the test account to experience the functions (SenparcRobot):

Senparc Network Assistant Official AccountSenparc Network Assistant Mini ProgramBookHelper

βœ‹ Contribute Code

If you need to use or modify the source code of this project, it is recommended to Fork first. You are also welcome to submit a Pull Request for the general version you modified.

  1. Fork
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the remote git repository (git push origin my-new-feature)
  5. Go to the my-new-feature branch of your git remote repository on the github website and submit a Pull Request
    (Submit to the Developer branch instead of the master branch directly)
<!-- ### /Controllers/WeixinController.cs The Token below needs to be synchronized with the Token set in the Wechat official platform backend. If it is frequently changed, it is recommended to write it into the Web.config or other configuration files (In actual use, it is recommended to use numbers + English letters in different cases to rewrite the Token. Once the Token is cracked, Wechat requests will be easily forged!): ```C# public readonly string Token = "weixin"; ``` The following Action (Get) is used to receive and return the verification result of the Wechat backend URL. No modification is required. The address is like: http://domain/Weixin or http://domain/Weixin/Index ```C# /// <summary> /// Wechat backend verification address (using Get), the "Interface Configuration Information" Url of Wechat backend is filled as: http://weixin.senparc.com/weixin /// </summary> [HttpGet] [ActionName("Index")] public ActionResult Get(PostModel postModel, string echostr) { if (CheckSignature.Check(postModel.Signature, postModel.Timestamp, postModel.Nonce, Token)) { return Content(echostr); // If a random string is returned, it means the verification is passed } else { return Content("failed:" + postModel.Signature + "," + MP.CheckSignature.GetSignature(postModel.Timestamp, postModel.Nonce, Token) + "。" + "If you see this sentence in the browser, it means that this address can be used as the Url of the Wechat official account backend. Please keep the Token consistent."); } } ``` The above method's PostModel is an entity class that includes Signature, Timestamp, Nonce (passed in by the Wechat server through the Url parameters when the request is made), as well as AppId, Token, EncodingAESKey and other sensitive information (needs to be passed in). It will also be used later. The following Action (Post) is used to receive Post requests from the Wechat server (usually initiated by the user). The if statement is essential here. The previous Get method only provides verification when the Wechat backend saves the Url. The verification must be re-verified for each Post, otherwise the request can be easily forged. ```C# /// <summary> /// After the user sends a message, the Wechat platform automatically posts a request here and waits for the XML response /// </summary> [HttpPost] [ActionName("Index")] public ActionResult Post(PostModel postModel) { if (!CheckSignature.Check(postModel.Signature, postModel.Timestamp, postModel.Nonce, Token)) { return Content("Parameter error!"); } ... } ``` ### How to handle Wechat official account requests? Senparc.Weixin.MP provides two ways to handle requests, the [conventional method](https://github.com/JeffreySu/WeiXinMPSDK/wiki/Handling-Wechat-messages-in-the-usual-way) and the [MessageHandler](https://github.com/JeffreySu/WeiXinMPSDK/wiki/How-to-use-MessageHandler-to-simplify-message-processing). The wiki has detailed explanations of these two methods. Here is a simple example of using the MessageHandler processing method. The processing flow of the MessageHandler is very simple: ``` C# [HttpPost] [ActionName("Index")] public ActionResult Post(PostModel postModel) { if (!CheckSignature.Check(postModel.Signature, postModel.Timestamp, postModel.Nonce, Token)) { return Content("Parameter error!"); } postModel.Token = Token; postModel.EncodingAESKey = EncodingAESKey;// Keep consistent with your own backend settings postModel.AppId = AppId;// Keep consistent with your own backend settings var messageHandler = new CustomMessageHandler(Request.InputStream, postModel);// Receive the message (first step) messageHandler.Execute();// Execute the Wechat processing process (second step) return new FixWeixinBugWeixinResult(messageHandler);// Return (third step) } ``` Except for the assignment of postModel in the above code, the receiving (first step), processing (second step), and returning (third step) of the message only require one line of code each. The CustomMessageHandler in the above code is a custom class that inherits from Senparc.Weixin.MP.MessageHandler.cs. MessageHandler is an abstract class that contains abstract methods for executing various request types (such as text, voice, location, image, etc.). We only need to implement these methods one by one in the CustomMessageHandler we created. The CustomMessageHandler.cs just created is as follows: ```C# using System; using System.IO; using Senparc.Weixin.MP.MessageHandlers; using Senparc.Weixin.MP.Entities; namespace Senparc.Weixin.MP.Sample.CustomerMessageHandler { public class CustomMessageHandler : MessageHandler<MessageContext> { public public CustomMessageHandler(Stream inputStream, PostModel postModel, int maxRecordCount = 0) : base(inputStream, postModel, maxRecordCount) { } public override IResponseMessageBase DefaultResponseMessage(IRequestMessageBase requestMessage) { //ResponseMessageText can also be News or other types var responseMessage = CreateResponseMessage<ResponseMessageText>(); responseMessage.Content = "This message is from DefaultResponseMessage."; return responseMessage; } public override IResponseMessageBase OnTextRequest(RequestMessageText requestMessage) { //... } public override IResponseMessageBase OnVoiceRequest(RequestMessageVoice requestMessage) { //... } //More OnXX methods that are not overridden will return the results in DefaultResponseMessage by default. .... } } ``` Where OnTextRequest, OnVoiceRequest, etc. correspond to different types of requests such as receiving text, voice, etc. For example, if we need to respond to text type requests, we just need to improve the OnTextRequest method: ```C# public override IResponseMessageBase OnTextRequest(RequestMessageText requestMessage) { //TODO: The logic here can be handed over to the Service to handle specific information. Refer to the OnLocationRequest method or /Service/LocationSercice.cs var responseMessage = CreateResponseMessage<ResponseMessageText>(); responseMessage.Content = string.Format("You just sent a text message: {0}", requestMessage.Content); return responseMessage; } ``` When CustomMessageHandler executes messageHandler.Execute(), if it finds that the request information type is text, it will automatically call the above code and return the responseMessage in the code as the returned information. responseMessage can be any type under the IResponseMessageBase interface (including text, news, multimedia, etc.). Starting from v0.4.0, MessageHandler adds support for user session context to solve the problem that user sessions cannot be managed on the server. See: [User Context WeixinContext and MessageContext](https://github.com/JeffreySu/WeiXinMPSDK/wiki/User-Context-WeixinContext-and-MessageContext) -->

πŸ‘©β€πŸ« How to develop with .NET Core

The current branch includes full code for .NET Framework 4.6.2+ and .NET 6.0/7.0/8.0/10.0 (for versions no longer updated, see release snapshots).

The Demo for .NET Framework is located in the /src/Samples/All/net45-mvc directory, and

[Recommended] The Demo for .NET 10.0 (compatible with .NET 5.0, 6.0, 7.0, 8.0, and .NET Core 3.1 and lower versions) is located in /Samples/All/net10-mvc.

Note: In the samples above, net10-mvc directly references each module's source code and can generate Senparc.Weixin SDK packages compatible with multiple versions when built in Release.

↕️ Install via Nuget to the project

The Nuget installation methods for each module: Installing the SDK into the project using Nuget

🏬 Deployment guide

1) Deploy to Azure App Service

App Service is a Web service launched by Microsoft Azure, which has good support for .NET. The deployment steps are detailed in: Deploy the Wechat site to Azure.

2) Deploy to any server via FTP

Install an FTP service on the web server (recommended: FileZilla Server), then upload your locally compiled code directly. The corresponding sample in Samples is Senparc.Weixin.Sample.Net10. It can be used directly after compilation without code changes. If you use Azure App Service or other cloud services, FTP is usually enabled as well.

<!-- Implemented Functions ------------- * Wechat Official Account > - [x] Receive/Send Messages (Events) > - [x] Custom Menu & Personalized Menu > - [x] Message Management > - [x] OAuth Authorization > - [x] JSSDK > - [x] Wechat Payment > - [x] User Management > - [x] Material Management > - [x] Account Management > - [x] Parameterized QR Code > - [x] Long URL to Short URL Interface > - [x] Wechat Authentication Event Push > - [x] Data Statistics > - [x] Wechat Store > - [x] Wechat Card Coupon > - [x] Card Coupon Event Push > - [ ] Payment Event Push > - [ ] Membership Card Content Update Event Push > - [ ] Inventory Alert Event Push > - [ ] Coupon Point Flow Detail Event Push > - [x] Wechat Store > - [x] Wechat Intelligence > - [x] Wechat Device Function > - [x] Customer Service Function > - [x] Wechat Shake Around > - [x] Wechat Wi-Fi (Incomplete) > - [x] Wechat Scan QR Code (Merchant) > - [ ] Scan QR Code Event Push > - [ ] Open Product Homepage Event Push > - [ ] Follow Official Account Event Push > - [ ] Enter Official Account Event Push > - [ ] Asynchronous Push of Geographic Location Information > - [ ] Product Audit Result Push * Wechat Open Platform > - [x] Website Application > - [x] Official Account Third-Party Platform * Wechat Work Account > - [x] Manage Address Book > - [x] Manage Material Files > - [x] Manage Enterprise Account Applications > - [x] Receive Messages and Events > - [x] Send Messages > - [x] Custom Menu > - [x] Identity Authentication Interface > - [x] JSSDK > - [x] Third-Party Application Authorization > - [x] Third-Party Callback Protocol > - [ ] Authorization Code Event Push > - [ ] Address Book Change Notification > - [x] Enterprise Account Authorization Login > - [x] Enterprise Account Wechat Payment > - [x] Enterprise Session Service > - [ ] Enterprise Session Callback > - [x] Enterprise Shake Around > - [ ] Enterprise Card Coupon Service > - [ ] Card Coupon Event Push > - [x] Enterprise Customer Service > - [ ] Customer Service Reply Message Callback * Cache Strategy > - [x] Strategy Extension Interface > - [x] Local Cache > - [x] Redis Extension Package > - [x] Memcached Extension Package Welcome developers to submit Pull Requests for unfinished or to-be-supplemented modules! -->

🍴 Important Branches

Β Branch Β Β  Β  Description Β  Β  Β  Β 
master Β The main branch for official releases. This branch is usually more stable and can be used in production environments.
Developer1. The development branch. This branch is usually the Beta version, and new versions are developed in this branch before being pushed to the master branch. If you want to get a sneak peek of new features, you can use this branch.
  1. This branch is compatible with .NET 4.5 / .NET Core / .NET Core 2.0 versions at the same time. It is recommended to submit Pull Requests for code to this branch instead of the master branch.
    | BookVersion1 | This branch is a code snapshot of the book In-Depth Analysis of Wechat Development: Efficient Development Secrets for Official Accounts and Mini Programs publication.
    | DotNET-Core_MySQL | This branch is a demonstration branch for integrating Pomelo.EntityFrameworkCore.MySql framework in .NET Core environment.
    | NET4.0 Β  Β  | Branch that only supports .NET 4.0. This branch was stopped updating in 2017. The latest code for .NET 4.0 is synchronized with the master / Developer branch.
    | NET3.5 Β  Β  | Branch that only supports .NET 3.5. This branch was stopped updating in 2015. The latest code for .NET 3.5 is synchronized with the master / Developer branch.
    | Developer-Senparc.SDK | This branch is only used for internal testing of the Senparc team and can be ignored.

🍟 Thanks To Contributors

Thanks to the developers who contributed to this project. You have not only improved this project, but also made a contribution to the Chinese open source community. Thank you! The list can be found here.

<a href="https://github.com/JeffreySu/WeiXinMPSDK/graphs/contributors"> </a>

πŸ’° Donations

If this project is useful to you, we welcome any form of donation, including participating in project code updates or providing feedback. Thank you!

Donate:

⭐ Star Quantity Statistics

πŸ“Š Project Operations Statistics

Star Growth Trend

Issues Opened and Closed Trend

Total NuGet Downloads

πŸ“Ž License

Apache License Version 2.0

Copyright 2025 Jeffrey Su & Suzhou Senparc Network Technology Co.,Ltd.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file 
except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the 
License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 
either express or implied. See the License for the specific language governing permissions 
and limitations under the License.

Detail: https://github.com/JeffreySu/WeiXinMPSDK/blob/master/license.md

[!TIP] 100% open source, commercial use supported.