Exemplo n.º 1
0
        /// <summary>
        /// system error request
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private async Task ReturnSystemError(HttpContext context)
        {
            BaseResponseResult response = new BaseResponseResult
            {
                Code    = "500",
                Message = "Some exception!"
            };

            context.Response.StatusCode = 500;
            await context.Response.WriteAsync(JsonConvert.SerializeObject(response));
        }
Exemplo n.º 2
0
        /// <summary>
        /// timeout request
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private async Task ReturnTimeOut(HttpContext context)
        {
            BaseResponseResult response = new BaseResponseResult
            {
                Code    = "408",
                Message = "Time Out!"
            };

            context.Response.StatusCode = 408;
            await context.Response.WriteAsync(JsonConvert.SerializeObject(response));
        }
Exemplo n.º 3
0
        private async Task ReturnRedirect(HttpContext context, string redictUrl)
        {
            BaseResponseResult response = new BaseResponseResult
            {
                Code    = "302",
                Message = "Need login!"
            };

            context.Response.StatusCode = 302;
            context.Response.Headers.Add("Location", redictUrl);
            await context.Response.WriteAsync(JsonConvert.SerializeObject(response));
        }
Exemplo n.º 4
0
        /// <summary>
        /// not authorized request
        /// 403返回码,表示无权限
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private async Task ReturnNoAuthorized(HttpContext context)
        {
            BaseResponseResult response = new BaseResponseResult
            {
                Code    = "401",
                Message = "You are not authorized!"
            };

            if (_options.noAuthoReturnok)
            {
                context.Response.StatusCode = 200;
            }
            else
            {
                context.Response.StatusCode = 403;
            }
            await context.Response.WriteAsync(JsonConvert.SerializeObject(response));
        }