C# 클래스 ChiakiYu.Common.Web.WebHelper

提供与Web请求时可使用的工具类,包括Url解析、Url/Html编码、获取IP地址、返回http状态码
파일 보기 프로젝트 열기: andyshao/ChiakiYu

공개 프로퍼티들

프로퍼티 타입 설명
HtmlNewLine string

공개 메소드들

메소드 설명
FormatCompleteUrl ( string content ) : string

把content中的虚拟路径转化成完整的url

例如: /abc/e.aspx 转化成 http://www.spacebuilder.cn/abc/e.aspx

GetIP ( ) : string

获取IP地址

GetIP ( HttpContext httpContext ) : string

透过代理获取真实IP

GetPhysicalFilePath ( string filePath ) : string

获取物理文件路径

GetServerDomain ( Uri uri, string domainRules ) : string

获取根域名

HostPath ( Uri uri ) : string

获取带传输协议的完整的主机地址

HtmlDecode ( string rawContent ) : string

html解码

HtmlEncode ( string rawContent ) : string

html编码

调用HttpUtility.HtmlEncode(),当前已知仅作如下转换:

< = &lt; > = &gt; & = &amp; " = &quot;
ResolveUrl ( string relativeUrl ) : string

将URL转换为在请求客户端可用的 URL(转换 ~/ 为绝对路径)

Return304 ( HttpContext httpContext, bool endResponse = true ) : void

返回 StatusCode 304

Return403 ( HttpContext httpContext ) : void

返回 StatusCode 403

Return404 ( HttpContext httpContext ) : void

返回 StatusCode 404

SetStatusCodeForError ( System.Web.HttpResponseBase response ) : void

设置当前响应的状态码为指定值

UrlDecode ( string urlToDecode ) : string

Url解码

UrlEncode ( string urlToEncode ) : string

Url编码

비공개 메소드들

메소드 설명
ReturnStatusCode ( HttpContext httpContext, int statusCode, string status, bool endResponse ) : void

返回http状态码

메소드 상세

FormatCompleteUrl() 공개 정적인 메소드

把content中的虚拟路径转化成完整的url
例如: /abc/e.aspx 转化成 http://www.spacebuilder.cn/abc/e.aspx
public static FormatCompleteUrl ( string content ) : string
content string content
리턴 string

GetIP() 공개 정적인 메소드

获取IP地址
public static GetIP ( ) : string
리턴 string

GetIP() 공개 정적인 메소드

透过代理获取真实IP
public static GetIP ( HttpContext httpContext ) : string
httpContext System.Web.HttpContext HttpContext
리턴 string

GetPhysicalFilePath() 공개 정적인 메소드

获取物理文件路径
public static GetPhysicalFilePath ( string filePath ) : string
filePath string /// /// filePath支持以下格式: /// /// ~/abc/ /// c:\abc\ /// \\192.168.0.1\abc\ /// /// ///
리턴 string

GetServerDomain() 공개 정적인 메소드

获取根域名
public static GetServerDomain ( Uri uri, string domainRules ) : string
uri System.Uri uri
domainRules string 域名规则
리턴 string

HostPath() 공개 정적인 메소드

获取带传输协议的完整的主机地址
public static HostPath ( Uri uri ) : string
uri System.Uri Uri
리턴 string

HtmlDecode() 공개 정적인 메소드

html解码
public static HtmlDecode ( string rawContent ) : string
rawContent string 待解码的字符串
리턴 string

HtmlEncode() 공개 정적인 메소드

html编码

调用HttpUtility.HtmlEncode(),当前已知仅作如下转换:

< = &lt; > = &gt; & = &amp; " = &quot;
public static HtmlEncode ( string rawContent ) : string
rawContent string 待编码的字符串
리턴 string

ResolveUrl() 공개 정적인 메소드

将URL转换为在请求客户端可用的 URL(转换 ~/ 为绝对路径)
public static ResolveUrl ( string relativeUrl ) : string
relativeUrl string 相对url
리턴 string

Return304() 공개 정적인 메소드

返回 StatusCode 304
public static Return304 ( HttpContext httpContext, bool endResponse = true ) : void
httpContext System.Web.HttpContext HttpContext
endResponse bool 是否终止HttpResponse
리턴 void

Return403() 공개 정적인 메소드

返回 StatusCode 403
public static Return403 ( HttpContext httpContext ) : void
httpContext System.Web.HttpContext HttpContext
리턴 void

Return404() 공개 정적인 메소드

返回 StatusCode 404
public static Return404 ( HttpContext httpContext ) : void
httpContext System.Web.HttpContext HttpContext
리턴 void

SetStatusCodeForError() 공개 정적인 메소드

设置当前响应的状态码为指定值
public static SetStatusCodeForError ( System.Web.HttpResponseBase response ) : void
response System.Web.HttpResponseBase 当前响应
리턴 void

UrlDecode() 공개 정적인 메소드

Url解码
public static UrlDecode ( string urlToDecode ) : string
urlToDecode string 待解码的字符串
리턴 string

UrlEncode() 공개 정적인 메소드

Url编码
public static UrlEncode ( string urlToEncode ) : string
urlToEncode string 待编码的url字符串
리턴 string

프로퍼티 상세

HtmlNewLine 공개적으로 정적으로 프로퍼티

public static string HtmlNewLine
리턴 string