JeffreySu/WeiXinMPSDK · error · MessageHandlerException
微信公众号不支持 IRequestMessageMiniProgramPage 响应类型
Error message
微信公众号不支持 IRequestMessageMiniProgramPage 响应类型
What it means
MpMessageEntityEnlightener.NewRequestMessageMiniProgramPage throws MessageHandlerException because the MP (公众号) platform has no IRequestMessageMiniProgramPage implementation; that request entity type belongs to other WeChat surfaces (e.g. 小程序/WxOpen). The MP enlightener is contractually required to implement the factory method, but it can only fail loudly when invoked.
Solutions
- Do not construct IRequestMessageMiniProgramPage in MP code; use the WxOpen/mini-program module for that message type.
- Branch on platform/module before building request entities, skipping MiniProgramPage for MP handlers.
- If you need mini-program page messages in a shared service, reference the appropriate enlightener per platform rather than a single MP instance.
- Inspect RequestMessage.MsgType before dispatching and route miniprogrampage types to the mini-program handler pipeline.
Example fix
// before
var request = mpEnlightener.NewRequestMessageMiniProgramPage(); // throws on MP
// after
if (platform == WechatPlatform.WxOpen)
request = wxOpenEnlightener.NewRequestMessageMiniProgramPage();
else
request = mpEnlightener.NewRequestMessageText(); // supported MP type Defensive patterns
Strategy: validation
Validate before calling
if (requestType == RequestMessageTypeEnum.MiniProgramPage /* or msgType == "miniprogrampage" */)
throw new InvalidOperationException("MiniProgramPage request entities require the WxOpen module, not MP."); Type guard
bool IsMpSupportedRequest(IRequestMessageBase r) =>
r is not IRequestMessageMiniProgramPage; // MP handlers must never build this type Try / catch
try
{
request = enlightener.NewRequestMessageMiniProgramPage();
}
catch (MessageHandlerException ex) when (ex.Message.Contains("IRequestMessageMiniProgramPage"))
{
logger.LogError(ex, "MiniProgramPage entities are not available in MP; use WxOpen module");
throw;
} Prevention
- Route miniprogrampage message types to the Senparc.Weixin.WxOpen handler pipeline, not MP.
- Keep MP and mini-program message builders in separate modules/services.
- Filter request-type enums by platform before generic entity construction.
- Add a unit test asserting MP enlightener never returns IRequestMessageMiniProgramPage.
When it happens
Trigger: Calling NewRequestMessageMiniProgramPage() on an MP MessageEntityEnlightener, or generic request-entity construction code that iterates request message types and includes MiniProgramPage while running under the MP module.
Common situations: Shared message-construction helpers written for the 小程序 (Senparc.Weixin.WxOpen / 小程序客服) reused against MP handlers; reflection-based or enum-driven entity builders that don't filter by platform; confusion between 公众号 message types and 小程序 page-push message types.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- 微信公众号不支持 IResponseMessageMpNews 响应类型
- MsgType: 在RequestMessageFactory中没有对应的处理程序!
- 请使用异步方法 OnExecutingAsync()
- 请使用异步方法 OnExecutedAsync()
- 微信请求发生错误!错误代码: ,说明:
AI-assisted analysis of JeffreySu/WeiXinMPSDK@be573f6f94 (2026-09-12).
Data as JSON: /api/errors/6beebcaa817af0a8.
Report an issue: GitHub.
Appendix: source
Thrown at src/Senparc.Weixin.MP/Senparc.Weixin.MP/MessageHandlers/MpMessageEntityEnlightener.cs:111
public override IResponseMessageTransfer_Customer_Service NewResponseMessageTransfer_Customer_Service()
{
return new ResponseMessageTransfer_Customer_Service();
}
public override IResponseMessageVideo NewResponseMessageVideo()
{
return new ResponseMessageVideo();
}
public override IResponseMessageVoice NewResponseMessageVoice()
{
return new ResponseMessageVoice();
}
public override IRequestMessageMiniProgramPage NewRequestMessageMiniProgramPage()
{
throw new MessageHandlerException("微信公众号不支持 IRequestMessageMiniProgramPage 响应类型");
}
}
}
View on GitHub (pinned to be573f6f94)