public async Task <IActionResult> Register() { string json = null; try { Request.EnableBuffering(); using (var stream = Request.Body) { using (var reader = new StreamReader(stream)) { json = await reader.ReadToEndAsync(); } } //1、数据验证 if (string.IsNullOrEmpty(json)) { return(Base.AjaxBase.ResponseAjax(400, 400, "The data is incomplete,Fail plaese again", Config.Instance, null)); } //2、接收请求数据并转化成为自己所需要的数据格式struct var service = JSON.Deserialize <SRCMessage>(json); if (service.service_id == "" || service.service_name == "") { return(Base.AjaxBase.ResponseAjax(400, 400, "service_id or service_name not is not allowed!", Config.Instance)); } else { SRC.Register(service); SRC.Send(service); //这里data:不需要返回 return(Base.AjaxBase.ResponseAjax(200, 200, "register service successful", Config.Instance, null)); } } catch (Exception e) { LogHelper.Error(e, Config.logName); return(Base.AjaxBase.ResponseAjax(400, 400, e.Message.ToString(), Config.Instance, null)); } }