JeffreySu/WeiXinMPSDK · error · MessageHandlerException
微信公众号不支持 IRequestMessageLocation 请求类型
Error message
微信公众号不支持 IRequestMessageLocation 请求类型
What it means
WxOpenMessageEntityEnlightener.NewRequestMessageLocation throws MessageHandlerException because location request messages are not part of the mini-program message protocol; the override exists solely to fulfill the base interface. It fires whenever a location-type request is processed by a WxOpen handler.
Solutions
- Route location messages to the OfficialAccount MessageHandler
- Reject/handle unsupported MsgTypes (location, link, file, video/shortvideo) before passing XML to the WxOpen handler
- Catch MessageHandlerException in the processing pipeline and respond with success to stop WeChat retries while logging the event
- Verify the mini-program callback only receives its supported message set
Example fix
// before
var result = await wxOpenHandler.ExecuteAsync(xml); // location message -> throws
// after
try {
var result = await wxOpenHandler.ExecuteAsync(xml);
} catch (MessageHandlerException ex) {
logger.LogWarning("Unsupported msg for WxOpen handler: {0}", ex.Message);
return new WeixinResult("success");
} Defensive patterns
Strategy: try-catch
Validate before calling
if (requestMsgType == RequestMsgType.Location) {
return officialAccountHandler.ExecuteAsync(xml); // location belongs to公众号
} Type guard
bool WxOpenSupportsType(RequestMsgType t) => t is RequestMsgType.Text or RequestMsgType.Image or RequestMsgType.Event;
Try / catch
try {
return await wxOpenHandler.ExecuteAsync(xml);
} catch (MessageHandlerException ex) when (ex.Message.Contains("IRequestMessageLocation")) {
logger.LogWarning("Location message sent to WxOpen handler; ignoring");
return new WeixinResult("success");
} Prevention
- Route location-type callbacks to the公众号 MessageHandler
- Separate mini-program and公众号 callback endpoints in WeChat configuration
- Pre-filter MsgTypes not supported by the WxOpen handler
- Reply 'success' on unsupported types to stop platform retries
When it happens
Trigger: A MsgType=location message delivered to WxOpenMessageHandler (usually misrouted OfficialAccount traffic) or a direct call to NewRequestMessageLocation on the WxOpen enlightener.
Common situations: Callback URL shared between公众号 and小程序; custom dispatcher forwarding all公众号 message types into the WxOpen pipeline; tests enumerating all factory methods.
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
- 微信公众号不支持 IRequestMessageFile 请求类型
- 微信公众号不支持 IRequestMessageLink 请求类型
- MsgType: 在RequestMessageFactory中没有对应的处理程序!
- 凭据提供器返回了空 AppSecret。
- SessionId无效(01)
AI-assisted analysis of JeffreySu/WeiXinMPSDK@be573f6f94 (2026-09-12).
Data as JSON: /api/errors/f3df3b6a486cc42d.
Report an issue: GitHub.
Appendix: source
Thrown at src/Senparc.Weixin.WxOpen/src/Senparc.Weixin.WxOpen/Senparc.Weixin.WxOpen/MessageHandlers/WxOpenMessageEntityEnlightener.cs:39
public override IRequestMessageFile NewRequestMessageFile()
{
throw new MessageHandlerException("微信公众号不支持 IRequestMessageFile 请求类型");
}
public override IRequestMessageImage NewRequestMessageImage()
{
return new RequestMessageImage();
}
public override IRequestMessageLink NewRequestMessageLink()
{
throw new MessageHandlerException("微信公众号不支持 IRequestMessageLink 请求类型");
}
public override IRequestMessageLocation NewRequestMessageLocation()
{
throw new MessageHandlerException("微信公众号不支持 IRequestMessageLocation 请求类型");
}
public override IRequestMessageShortVideo NewRequestMessageShortVideo()
{
throw new MessageHandlerException("微信公众号不支持 IRequestMessageShortVideo 请求类型");
}
public override IRequestMessageText NewRequestMessageText()
{
return new RequestMessageText();
}
public override IRequestMessageVideo NewRequestMessageVideo()
{
throw new MessageHandlerException("微信公众号不支持 IRequestMessageVideo 请求类型");
}
public override IRequestMessageVoice NewRequestMessageVoice()View on GitHub (pinned to be573f6f94)