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提交处理

相关文章:

  • 2021-11-30
  • 2021-10-24
  • 2022-12-23
  • 2022-12-23
  • 2022-01-19
  • 2021-06-28
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-11-03
  • 2022-12-23
  • 2022-01-04
  • 2021-12-24
  • 2022-01-31
  • 2021-08-07
相关资源
相似解决方案