类里的内容:
using System.Web.Http;
namespace WebServiceHospital
{
public class zhifuController : ApiController
{
public string Weixin_ZhiFu_Toface_Notify()
{
return "<xml><return_code><![CDATA[SUCCESS]]></return_code><return_msg><![CDATA[OK]]></return_msg></xml>";
}
}
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "{controller}/{action}/{id}",
defaults: new { id = RouteParameter.Optional }
);
}
}
}
关键:在Application_Start里添加路由
GlobalConfiguration.Configure(WebApiConfig.Register);
可以正常接收POST请求了