You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
using Newtonsoft.Json; using System; using System.Web;
/// <summary>
/// Handler 的摘要说明
/// </summary>
public abstract class Handler { protected Handler(HttpContext context) { this.Request = context.Request; this.Response = context.Response; this.Context = context; this.Server = context.Server; }
public abstract void Process();
protected void WriteJson(object response) { var jsonpCallback = Request["callback"]; var json = JsonConvert.SerializeObject(response); if (String.IsNullOrWhiteSpace(jsonpCallback)) { Response.AddHeader("Content-Type", "text/plain"); Response.Write(json); } else { Response.AddHeader("Content-Type", "application/javascript"); Response.Write($"{jsonpCallback}({json});"); } Response.End(); }
public HttpRequest Request { get; private set; } public HttpResponse Response { get; private set; } public HttpContext Context { get; private set; } public HttpServerUtility Server { get; private set; } }
|