{"record":{"id":"6beebcaa817af0a8","repo":"JeffreySu/WeiXinMPSDK","slug":"irequestmessageminiprogrampage","errorCode":null,"errorMessage":"微信公众号不支持 IRequestMessageMiniProgramPage 响应类型","messagePattern":"微信公众号不支持 IRequestMessageMiniProgramPage 响应类型","errorType":"exception","errorClass":"MessageHandlerException","httpStatus":null,"severity":"error","filePath":"src/Senparc.Weixin.MP/Senparc.Weixin.MP/MessageHandlers/MpMessageEntityEnlightener.cs","lineNumber":111,"sourceCode":"\n        public override IResponseMessageTransfer_Customer_Service NewResponseMessageTransfer_Customer_Service()\n        {\n            return new ResponseMessageTransfer_Customer_Service();\n        }\n\n        public override IResponseMessageVideo NewResponseMessageVideo()\n        {\n            return new ResponseMessageVideo();\n        }\n\n        public override IResponseMessageVoice NewResponseMessageVoice()\n        {\n            return new ResponseMessageVoice();\n        }\n\n        public override IRequestMessageMiniProgramPage NewRequestMessageMiniProgramPage()\n        {\n            throw new MessageHandlerException(\"微信公众号不支持 IRequestMessageMiniProgramPage 响应类型\");\n        }\n    }\n}\n","sourceCodeStart":93,"sourceCodeEnd":115,"githubUrl":"https://github.com/JeffreySu/WeiXinMPSDK/blob/be573f6f94bdbf718dd5f6cdecb137fbc7ff651e/src/Senparc.Weixin.MP/Senparc.Weixin.MP/MessageHandlers/MpMessageEntityEnlightener.cs#L93-L115","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nvar request = mpEnlightener.NewRequestMessageMiniProgramPage(); // throws on MP\n\n// after\nif (platform == WechatPlatform.WxOpen)\n    request = wxOpenEnlightener.NewRequestMessageMiniProgramPage();\nelse\n    request = mpEnlightener.NewRequestMessageText(); // supported MP type","handlingStrategy":"validation","validationCode":"if (requestType == RequestMessageTypeEnum.MiniProgramPage /* or msgType == \"miniprogrampage\" */)\n    throw new InvalidOperationException(\"MiniProgramPage request entities require the WxOpen module, not MP.\");","typeGuard":"bool IsMpSupportedRequest(IRequestMessageBase r) =>\n    r is not IRequestMessageMiniProgramPage; // MP handlers must never build this type","tryCatchPattern":"try\n{\n    request = enlightener.NewRequestMessageMiniProgramPage();\n}\ncatch (MessageHandlerException ex) when (ex.Message.Contains(\"IRequestMessageMiniProgramPage\"))\n{\n    logger.LogError(ex, \"MiniProgramPage entities are not available in MP; use WxOpen module\");\n    throw;\n}","preventionTips":["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."],"tags":["wechat","messagehandler","miniprogram","unsupported-request-type","platform"],"backgroundTag":"unsupported-operation","analyzedSha":"be573f6f94bdbf718dd5f6cdecb137fbc7ff651e","analyzedAt":"2026-09-12T10:01:50.733Z","contentChangedAt":"2026-09-12T10:01:50.733Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}