1.打开Startup.cs
在ConfigureServices中添加 services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
2.接收回调类中添加
private readonly IHttpContextAccessor _accessor;
3.接收并解析微信通知
var httpcontext = _accessor.HttpContext;
Stream s = httpcontext.Request.Body;
StreamReader reader = new StreamReader(s);
string postStr = reader.ReadToEnd();
var res = XDocument.Parse(postStr);