一、报错:“MessageDetail“: “在控制器“Other”上找不到与该请求匹配的操作。“

"Message": "找不到与请求 URI“http://localhost:19496/api/BMS/Testaaa”匹配的 HTTP 资源。",
"MessageDetail": "在控制器“Other”上找不到与该请求匹配的操作。"
	    /// <summary>
        /// 车辆治超检测统计
        /// </summary>      
        /// <returns></returns>
        [Route("GovernanceStationInfo")]
        [HttpPost]
        [AllowAnonymous]
        public IHttpActionResult GovernanceStationInfo( string dateTime)
        {
            TipsModel<List<OverloadCtrlEntity>> tipsWeb = new TipsModel<List<OverloadCtrlEntity>>(false);
            GovernanceStationInfoService service = new GovernanceStationInfoService();
            try
            {
                TipsModel<PagedList<OverloadCtrlEntity>> tips = new TipsModel<PagedList<OverloadCtrlEntity>>();
                List<string> str = new List<string> { "1112323232323"};
                var tests = InstanceHelper<OverloadCtrlStorage>.GetInstance().GetPageData(str, DateTime.Parse(dateTime), DateTime.Now, 1, 10000);
                return Json(tests);
            }
            catch (Exception ex)
            {
            }
            return Json(tipsWeb);
        }

二、解决方案------在参数前加[FromBody]

	    /// <summary>
        /// 车辆治超检测统计
        /// </summary>      
        /// <returns></returns>
        [Route("GovernanceStationInfo")]
        [HttpPost]
        [AllowAnonymous]
        public IHttpActionResult GovernanceStationInfo([FromBody] string dateTime)
        {
            TipsModel<List<OverloadCtrlEntity>> tipsWeb = new TipsModel<List<OverloadCtrlEntity>>(false);
            GovernanceStationInfoService service = new GovernanceStationInfoService();
            try
            {
                TipsModel<PagedList<OverloadCtrlEntity>> tips = new TipsModel<PagedList<OverloadCtrlEntity>>();
                List<string> str = new List<string> { "1112323232323"};
                var tests = InstanceHelper<OverloadCtrlStorage>.GetInstance().GetPageData(str, DateTime.Parse(dateTime), DateTime.Now, 1, 10000);
                return Json(tests);
            }
            catch (Exception ex)
            {
            }
            return Json(tipsWeb);
        }
Logo

开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!

更多推荐