Asp.Net WebApi Action命名中已‘Get’开头问题

ApiController 中的Action 命名已‘Get’开头,Post方法提交失败。

场景:

1.action命名使用Get开头

        /// <summary>
        /// 获取用户的未读消息数量
        /// </summary>
        /// <returns></returns>
        public string GetMsgNoRead()
        {
            return new A_UserMessageHelper().GetCount_NoRead_User().ToString();
        }

2.启用两个JSONP的跨域处理

public class JsonpMediaTypeFormatter : JsonMediaTypeFormatter

解决方案:

在对Action命名的时候不使用’Get‘开头即可。

特别说明,对于Get请求的方法命名‘GetXXX’使用‘Get’开头,对于Post请求处理不使用‘GetXXX’

更多:

Asp.Net WebApi Get请求说明(一)

Asp.Net WebAPI Get提交、Post提交处理

原文地址:https://www.cnblogs.com/tianma3798/p/5358386.html