1. JavaScript
코드 사본은 다음과 같습니다.
/**
* HTTP 요청의 참조자를 받으십시오
* @ishost 부울 참조자가 비어있을 때 호스트를 반환할지 여부 (홈페이지 주소)
*/
함수 get_http_referer (ishost) {
if (ishost === undefined) {ishost = true; }
if (document.referrer) {
RETURN DOCKING.REFERRER;
} 또 다른 {
if (ishost) {
Return Window.location.protocol + "//" + Window.location.host;
} 또 다른 {
반품 "";
}
}
}
2. C#
코드 사본은 다음과 같습니다.
/// <요약>
/// http 요청 상자를받습니다
/// </summary>
/// <param name = "ishost"> 참조자가 비어있을 때 호스트를 반환할지 (홈페이지의 주소) </param>
/// <Returns> String </returns>
공개 문자열 getReferer (bool ishost)
{
if (request.urlreferrer! = null)
{
return request.urlreferrer.toString ();
}
또 다른
{
if (ishost)
{
return request.url.scheme + ": //" + request.url.authority;
}
또 다른
{
반품 "";
}
}
}
3. 요청 URL의 다양한 부분을 C#에서 얻습니다.
웹 사이트 : http : // localhost : 1897/news/press/content.aspx/123? id = 1#toc
코드 사본은 다음과 같습니다.
request.applicationpath/
request.physicalpathd : /projects/solution/web/news/press/content.aspx
System.io.path.getDirectoryName (request.physicalpath) d :/project/solution/web/news/press
request.physicalApplicationPathd :/projects/solution/web/
System.io.path.getFilename (request.physicalpath) content.aspx
request.currentExecutionFilePath/News/Press/Content.aspx
request.filepath/news/press/content.aspx
request.path/news/press/content.aspx/123
request.rawurl/news/press/content.aspx/123? id = 1
request.url.absolutepath/news/press/content.aspx/123
request.url.absoluteurihttp : // localhost : 1897/news/press/content.aspx/123? id = 1
request.url.schemehttp
request.url.hostlocalhost
request.url.port1897
request.url.authoritylocalhost : 1897
request.url.localpath/news/press/content.aspx/123
request.pathinfo/123
request.url.pathandquery/news/press/content.aspx/123? id = 1
request.url.query? id = 1
request.url.fragment
request.url.segments/
소식/
누르다/
content.aspx/
123
4. JavaScript Window.location 객체
//www.vevb.com/article/57407.htm
어때? JavaScript와 C#에서 페이지의 참조를 얻는 법을 배웠습니까? 궁금한 점이 있으면 저에게 연락하십시오.