(item == null) 5 //未找到返回一个404的状态码 6 throw new HttpResponseException(HttpStatusCode.NotFound...//未找到返回一个404的状态码 6 { 7 var resp = new HttpResponseMessage(HttpStatusCode.NotFound...= null) 5 return Request.CreateResponse(HttpStatusCode.OK, item); 6 var message...= null) 5 return Request.CreateResponse(HttpStatusCode.OK, item); 6 var message...= null) 5 return Request.CreateResponse(HttpStatusCode.OK, item); 6 var
GetMenuResult result = CommonApi.GetMenu(WeixinConfig.APPID); return Request.CreateResponse(HttpStatusCode.OK...catch (WeixinException e) { return Request.CreateErrorResponse(HttpStatusCode.InternalServerError...result }; return response; } return Request.CreateErrorResponse(HttpStatusCode.BadRequest...HttpContext.Current.SideInWeixinBroswer()) { return Request.CreateErrorResponse(HttpStatusCode.Forbidden...ticket, nonceStr, timestamp, HttpUtility.UrlDecode(url)); return Request.CreateResponse(HttpStatusCode.OK
---- CSharp 对应的 HttpStatusCode 如下: public enum HttpStatusCode { // // 摘要: //...System.Net.HttpStatusCode.Ambiguous 指示请求的信息有多种表示形式。...System.Net.HttpStatusCode.BadRequest 指示服务器未能识别请求。...System.Net.HttpStatusCode.Unauthorized 指示请求的资源要求身份验证。...System.Net.HttpStatusCode.Gone 指示请求的资源不再可用。
Product item = repository.Get(id); if (item == null) { throw new HttpResponseException(HttpStatusCode.NotFound...item = repository.Get(id); if (item == null) { var resp = new HttpResponseMessage(HttpStatusCode.NotFound..., err); } else { return Request.CreateResponse(HttpStatusCode.OK, item);..., message); } else { return Request.CreateResponse(HttpStatusCode.OK, item);..., err); } else { return Request.CreateResponse(HttpStatusCode.OK, item);
= HttpStatusCode.OK) return default(T); if (response.Data !...= HttpStatusCode.OK) return default(T); if(isData) { if (response.Data !... public static HttpStatusCode Post(string resource, object obj) { try { var request = new RestRequest...// /// 资源 /// Body /// HttpStatusCode... public static HttpStatusCode Put(string resource,object obj) { try { var request = new RestRequest
public class HttpException extends RuntimeException{ protected Integer code; protected Integer httpStatusCode...Integer code) { this.code = code; } public Integer getHttpStatusCode() { return httpStatusCode...; } public void setHttpStatusCode(Integer httpStatusCode) { this.httpStatusCode = httpStatusCode...class NotFoundException extends HttpException{ public NotFoundException(int code){ this.httpStatusCode
~/api/helloworld")] public HttpResponseMessage HelloWorld() { return Request.CreateResponse(HttpStatusCode.OK...)429, "Too many requests"); return Request.CreateResponse(HttpStatusCode.OK, "Hello World"); }...)429, "Too many requests"); return Request.CreateResponse(HttpStatusCode.OK, "Hello World"); }...)429, "Too many requests"); return Request.CreateResponse(HttpStatusCode.OK, "Hello World"); }...)429, "Too many requests"); else response = Request.CreateResponse(HttpStatusCode.OK, content
id); if (item == null) { throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.NotFound...item = repository.Get(id); if (item == null) { var resp = new HttpResponseMessage(HttpStatusCode.NotFound...NotImplementedException) { context.Response = new HttpResponseMessage(HttpStatusCode.NotImplemented
); if (routeData == null) { throw new HttpResponseException(HttpStatusCode.NotFound...Version); if (version == null) { throw new HttpResponseException(HttpStatusCode.NotFound...if (controllerName == null) { throw new HttpResponseException(HttpStatusCode.NotFound...{ throw new HttpResponseException( request.CreateErrorResponse(HttpStatusCode.InternalServerError...request.")); } else { throw new HttpResponseException(HttpStatusCode.NotFound
) .OrResult(r => r.StatusCode == HttpStatusCode.BadGateway) // 处理元类型结果 (用.Equals...) Policy .HandleResult(HttpStatusCode.InternalServerError) .OrResult(HttpStatusCode.BadGateway) // 在一个policy里面同时处理异常和返回结果。...HttpStatusCode[] httpStatusCodesWorthRetrying = { HttpStatusCode.RequestTimeout, // 408 HttpStatusCode.InternalServerError..., // 500 HttpStatusCode.BadGateway, // 502 HttpStatusCode.ServiceUnavailable, // 503 HttpStatusCode.GatewayTimeout
File.Exists(filePath)) { response.StatusCode = (int)HttpStatusCode.NotFound...catch (ArgumentException) { response.StatusCode = (int)HttpStatusCode.BadRequest...response.OutputStream.Write(buffer, 0, buffer.Length); } response.StatusCode = (int)HttpStatusCode.OK...// 使用提供的编码写入文件 } } response.StatusCode = (int)HttpStatusCode.OK...ArgumentException) { // 编码不支持或无效 response.StatusCode = (int)HttpStatusCode.BadRequest
msg">错误信息/// 错误码/// HTTP状态代码的值,未登录和登录过期为HttpStatusCode.Unauthorized...,没有权限是HttpStatusCode.Forbidden/// 返回Result格式信息[NonAction]public IActionResult...ErrorResult(string msg, int code, HttpStatusCode statusCode = HttpStatusCode.OK){ return ToJsonContent
[SwaggerResponse(HttpStatusCode.OK, Type=typeof(IEnumerable))] [SwaggerResponseExample(HttpStatusCode.OK..., typeof(MyExamples))] [SwaggerResponse(HttpStatusCode.BadRequest, Type = typeof(IEnumerable<ErrorResource
questUrl.Contains(d))) { // 返回200的HTTP状态码 await ResponseForVerify(HttpStatusCode.OK...// 3、token为空,返回401 if (token.Cof_IsNullOrEmpty()) await ResponseForVerify(HttpStatusCode.Unauthorized...DateTime.Now}-{DateTime.Now.Millisecond};校验通过,用户id:{tokenModel.Uid}"); await ResponseForVerify(HttpStatusCode.OK...); return; } // 5、不满足上述情况,就返回403 await ResponseForVerify(HttpStatusCode.Unauthorized
actionExecutedContext.Response = actionExecutedContext.Request.CreateErrorResponse((HttpStatusCode...actionExecutedContext.Response = actionExecutedContext.Request.CreateErrorResponse(HttpStatusCode.InternalServerError
false) { actionContext.Response = actionContext.Request.CreateErrorResponse(HttpStatusCode.BadRequest...false) { actionContext.Response = actionContext.Request.CreateErrorResponse(HttpStatusCode.BadRequest...ModelState.IsValid) //{ // return BadRequest(ModelState); //} return StatusCode(HttpStatusCode.NoContent...false) { actionContext.Response = actionContext.Request.CreateErrorResponse(HttpStatusCode.BadRequest...} [Then(@"返回Bad Request")] public void Then() { Assert.AreEqual(HttpStatusCode.BadRequest
请求返回的结果 public static string Request(string method, string url, string param, Action请求返回的结果 public static string Post(string url, string param, Action请求返回结果 public static string Get(string url, string param, Action请求返回结果 private static string HttpRequest(HttpWebRequest request, Action<HttpStatusCode...= null) onComplete(HttpStatusCode.NotFound, "请求远程返回为空"); return null
= 10) { var resp = Request.CreateResponse(HttpStatusCode.OK, "请求已过期...DateTime.Now.AddMinutes(-5)) { var resp = Request.CreateResponse(HttpStatusCode.OK...string.IsNullOrWhiteSpace(errorMsg)) { var resp = Request.CreateResponse(HttpStatusCode.OK...= 10) { var resp = Request.CreateResponse(HttpStatusCode.OK, "请求已过期...DateTime.Now.AddMinutes(-5)) { var resp = Request.CreateResponse(HttpStatusCode.OK
) { var response = new HttpResponseMessage(); response.StatusCode = HttpStatusCode.NotFound... actionExecutedContext.Result = new HttpResponseMessage(); } //HttpStatusCode.NotImplemented...= 501 actionExecutedContext.Result.StatusCode = HttpStatusCode.NotImplemented ; ... //var response = new HttpResponseMessage(); //response.StatusCode = HttpStatusCode.NotFound
fileSavePath); fileNameList.Add(fileSavePath); } response = Request.CreateResponse(HttpStatusCode.OK..., fileNameList); } else { response = Request.CreateResponse(HttpStatusCode.BadRequest...restClient.ExecuteAsync(request, (response) => { if (response.StatusCode == HttpStatusCode.OK
领取专属 10元无门槛券
手把手带您无忧上云