httpContext.Response.Write(錯誤訊息);
httpContext.Response.StatusCode = (int)System.Net.HttpStatusCode.InternalServerError;
httpContext.Response.Flush();
httpContext.Response.SuppressContent = true;
httpContext.ApplicationInstance.CompleteRequest();
※若為 async 函數,await 後就無法再取得 System.Web.HttpContext.Current,必須先用變數記錄起來,await 之後再填回
var httpcontext = HttpContext.Current;
await xxxAsync().ConfigureAwait(false);
HttpContext.Current = httpcontext;
沒有留言:
張貼留言