C# Class ChiakiYu.Common.Web.WebHelper

提供与Web请求时可使用的工具类,包括Url解析、Url/Html编码、获取IP地址、返回http状态码
Show file Open project: andyshao/ChiakiYu

Public Properties

Property Type Description
HtmlNewLine string

Public Methods

Method Description
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编码

Private Methods

Method Description
ReturnStatusCode ( HttpContext httpContext, int statusCode, string status, bool endResponse ) : void

返回http状态码

Method Details

FormatCompleteUrl() public static method

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

GetIP() public static method

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

GetIP() public static method

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

GetPhysicalFilePath() public static method

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

GetServerDomain() public static method

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

HostPath() public static method

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

HtmlDecode() public static method

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

HtmlEncode() public static method

html编码

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

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

ResolveUrl() public static method

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

Return304() public static method

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

Return403() public static method

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

Return404() public static method

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

SetStatusCodeForError() public static method

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

UrlDecode() public static method

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

UrlEncode() public static method

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

Property Details

HtmlNewLine public static property

public static string HtmlNewLine
return string