Class ApiAshx
Namespace: Tool.Web.Api
Assembly: Tool.Net.dll
针对于新版Ashx路由模式,的同步,异步,支持
该控制器,相对于Mvc的控制器轻,应有功能都有,可自由扩展。
方便实现,您最想实现的效果,最大的优点还是因为他轻量级。
public abstract class ApiAshx : IHttpAsynApi, IHttpApi, IDisposableInheritance
Implements
IHttpAsynApi, IHttpApi, IDisposable
Inherited Members
object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.MemberwiseClone(), object.ReferenceEquals(object?, object?), object.ToString()
Extension Methods
ObjectExtension.Add<T>(object, object, object), ObjectExtension.CopyEntity(object, object, params string[]), ObjectExtension.EntityToJson(object), ObjectExtension.EntityToJson(object, bool), ObjectExtension.EntityToJson(object, bool, string), DictionaryExtension.GetDictionary(object), TypeExtension.GetFieldKey(object, string, out bool), TypeExtension.GetFieldKey<T>(object, string, out bool), TypeExtension.GetFieldKey(object, Type, string, out bool), ObjectExtension.GetIntPtr(object), ObjectExtension.GetIntPtrInt(object), TypeExtension.GetPropertieFind(object, string, bool), TypeExtension.GetProperties(object), TypeExtension.GetPropertyKey(object, string, out bool), TypeExtension.GetPropertyKey<T>(object, string, out bool), TypeExtension.GetPropertyKey(object, Type, string, out bool), TypeExtension.GetValue(object, PropertyDescriptor), TypeExtension.GetValue(object, string, bool), TypeExtension.GetValue(object, string), ObjectExtension.Read<T>(object, object, int, int), ObjectExtension.Read<T>(object, int, object, int, int), DictionaryExtension.SetDictionary(object, IDictionary<string, object>), TypeExtension.SetFieldKey(object, string, object), TypeExtension.SetFieldKey<T>(object, string, object), TypeExtension.SetFieldKey(object, Type, string, object), TypeExtension.SetPropertyKey(object, string, object), TypeExtension.SetPropertyKey<T>(object, string, object), TypeExtension.SetPropertyKey(object, Type, string, object), TypeExtension.SetValue(object, PropertyDescriptor, object), TypeExtension.SetValue(object, string, object, bool), TypeExtension.SetValue(object, string, object), ObjectExtension.ToBase64String(object), ObjectExtension.ToBytes(object), ObjectExtension.ToBytes(object, out Type), DictionaryExtension.ToDictionary(object), DictionaryExtension.ToDictionary<T>(object), DictionaryExtension.ToIDictionary(object), DictionaryExtension.ToIDictionary<T>(object), ObjectExtension.ToJson(object), ObjectExtension.ToJson(object, JsonSerializerOptions), ObjectExtension.ToJsonWeb(object), ObjectExtension.ToJsonWeb(object, Action<JsonSerializerOptions>), ObjectExtension.ToTryVar<T>(object, T), ObjectExtension.ToVar<T>(object), ObjectExtension.ToVar(object, Type, bool), ObjectExtension.ToVar(object, string), ObjectExtension.ToXml(object)
Remarks
代码由逆血提供支持
Properties
ApiKey
获取当前请求的接口唯一ID
public string ApiKey { get; }Property Value
ContentLength
指定客户端发送的内容长度(以字节计)。
public long? ContentLength { get; }Property Value
long?
ContentType
获取或设置传入请求的 MIME 内容类型。(ContentType)
public string ContentType { get; set; }Property Value
Context
获取当前 请求获取 对象。
public HttpContext Context { get; }Property Value
Cookies
获取客户端发送的 Cookie 的集合。
public IRequestCookieCollection Cookies { get; }Property Value
HttpMethod
获取客户端使用的 HTTP 数据传输方法(如 GET、POST 或 HEAD)。
public string HttpMethod { get; }Property Value
Request
获取当前 HTTP 请求的 对象。
public HttpRequest Request { get; }Property Value
RequestBody
获取传入的 HTTP 实体主体的内容。
public Stream RequestBody { get; }Property Value
Response
获取当前 HTTP 响应的 对象。
public HttpResponse Response { get; }Property Value
ResponseBody
启用到输出 HTTP 内容主体的二进制输出。
public Stream ResponseBody { get; }Property Value
Exceptions
Body 不可用。
RouteData
路由模式
public AshxRouteData RouteData { get; }Property Value
Session
为当前 HTTP 请求获取 对象。
public ISession Session { get; }Property Value
TotalBytes
获取当前输入流中的字节数。
public long TotalBytes { get; }Property Value
Methods
AshxException(AshxException)
当前API接口发生异常时触发
protected virtual void AshxException(AshxException ex)Parameters
异常信息
Initialize(Ashx)
当链接真实有效时被执行,默认返回成功。(该方法是用于给使用者重写的)
protected virtual bool Initialize(Ashx ashx)Parameters
ashx Ashx
当前可以被调起的接口信息
Returns
当前请求会根据返回状态决定是否继续执行接口方法
Json(object)
Json 格式输出,将 System.Object 写入 HTTP 响应流。
public void Json(object obj)Parameters
obj object
要写入 HTTP 输出流的 System.Object。
Json(object, JsonSerializerOptions)
Json 格式输出,将 System.Object 写入 HTTP 响应流。
public void Json(object obj, JsonSerializerOptions JsonOptions)Parameters
obj object
要写入 HTTP 输出流的 System.Object。
JsonOptions JsonSerializerOptions
Json 特殊格式输出
JsonAsync(object)
Json 格式输出,将 System.Object 写入 HTTP 响应流。
public Task JsonAsync(object obj)Parameters
obj object
要写入 HTTP 输出流的 System.Object。
Returns
JsonAsync(object, JsonSerializerOptions)
Json 格式输出,将 System.Object 写入 HTTP 响应流。
public Task JsonAsync(object obj, JsonSerializerOptions JsonOptions)Parameters
obj object
要写入 HTTP 输出流的 System.Object。
JsonOptions JsonSerializerOptions
Json 特殊格式输出
Returns
OnResult(Ashx)
在请求正常完成结束时触发
protected virtual void OnResult(Ashx ashx)Parameters
ashx Ashx
获取接口信息
Redirect(string, bool)
将客户端重定向到新的 URL。 指定新的 URL 并指定当前页的执行是否应终止。
public void Redirect(string url, bool endResponse)Parameters
url string
目标的位置。
endResponse bool
指示当前页的执行是否应终止。
Exceptions
url 为 null。
url 包含换行符。
在发送了 HTTP 头之后尝试重定向。
页请求是回调的结果。
Redirect(string)
将请求重定向到新 URL 并指定该新 URL。
public void Redirect(string url)Parameters
url string
目标位置。
Exceptions
在发送了 HTTP 头之后尝试重定向。
Write(object)
将 System.Object 写入 HTTP 响应流。
public void Write(object obj)Parameters
obj object
要写入 HTTP 输出流的 System.Object。
Write(string)
将一个字符串写入 HTTP 响应输出流。
public void Write(string test)Parameters
test string
要写入 HTTP 输出流的字符串。
Write(object, WriteType)
将 System.Object 写入 HTTP 响应流。
public void Write(object obj, WriteType contentType)Parameters
obj object
要写入 HTTP 输出流的 System.Object。
contentType WriteType
返回客户端的类型
WriteAsync(object)
将 System.Object 写入 HTTP 响应流。
public Task WriteAsync(object obj)Parameters
obj object
要写入 HTTP 输出流的 System.Object。
Returns
WriteAsync(string)
将一个字符串写入 HTTP 响应输出流。
public Task WriteAsync(string test)Parameters
test string
要写入 HTTP 输出流的字符串。
Returns
WriteAsync(object, WriteType)
将 System.Object 写入 HTTP 响应流。
public Task WriteAsync(object obj, WriteType contentType)Parameters
obj object
要写入 HTTP 输出流的 System.Object。
contentType WriteType
返回客户端的类型