JeffreySu/WeiXinMPSDK · error · MessageHandlerException
微信企业号不支持 IRequestMessageMiniProgramPage 响应类型
Error message
微信企业号不支持 IRequestMessageMiniProgramPage 响应类型
What it means
NewRequestMessageMiniProgramPage() throws MessageHandlerException because WeChat Work requests never produce a mini-program-page request message; this request entity type is unsupported in the Work platform, so the enlightener refuses to instantiate it.
Solutions
- Do not instantiate IRequestMessageMiniProgramPage in Work handlers; use the supported Work request entity types.
- Gate the call behind a platform check so mini-program request entities are only created in MP handlers.
- If you need mini-program handling under Work, handle it via the appropriate Work event/message types instead.
Example fix
// before var req = messageHandler.NewRequestMessageMiniProgramPage(); // after var req = messageHandler.NewRequestMessageText(); // supported Work request type
Defensive patterns
Strategy: type-guard
Validate before calling
if (requestMessage is IRequestMessageMiniProgramPage) { /* MP only — never valid in Work */ } Type guard
bool IsMiniProgramRequest(IWorkRequestMessageBase req) => req is Senparc.Weixin.Work.RequestMessageMiniProgramPage; // will simply never match; guard before instantiating
Try / catch
try
{
req = messageHandler.NewRequestMessageMiniProgramPage();
}
catch (MessageHandlerException)
{
req = messageHandler.NewRequestMessageText();
} Prevention
- Only instantiate mini-program request entities in MP message handlers.
- Avoid reflection-based loops that create every request entity type regardless of platform.
When it happens
Trigger: Calling NewRequestMessageMiniProgramPage() on the Work message handler, e.g. in generic code that enumerates all request entity types regardless of platform.
Common situations: Shared test helpers or reflection-driven handler scaffolding that instantiates request entities for both MP and Work; mini-program page messages only occur on the MP platform.
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 响应类型
- 微信企业号不支持 IResponseMessageMusic 响应类型
- 微信企业号不支持 IResponseMessageTransfer_Customer_Service 响应类型
- 请使用异步方法 OnExecutedAsync()
- 请使用异步方法 OnExecutingAsync()
AI-assisted analysis of JeffreySu/WeiXinMPSDK@be573f6f94 (2026-09-12).
Data as JSON: /api/errors/e20558a4754e3e29.
Report an issue: GitHub.
Appendix: source
Thrown at src/Senparc.Weixin.Work/Senparc.Weixin.Work/MessageHandlers/WorkMessageEntityEnlightener.cs:106
public override IResponseMessageTransfer_Customer_Service NewResponseMessageTransfer_Customer_Service()
{
throw new MessageHandlerException("微信企业号不支持 IResponseMessageTransfer_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)