1. Javascript
Кода -копия выглядит следующим образом:
/**
* Получите реферер HTTP -запроса
* @Ishost, чтобы вернуть хост, когда логический рефарер пуст (адрес домашней страницы)
*/
Функция get_http_referer (ishost) {
if (ishost === не определено) {ishost = true; }
if (document.referrer) {
return Document.ReferRer;
} еще {
if (ishost) {
return window.location.protocol + "//" + window.location.host;
} еще {
возвращаться "";
}
}
}
2. C#
Кода -копия выглядит следующим образом:
/// <summary>
/// Получите реферат HTTP -запрос
/// </summary>
/// <param name = "ishost"> вернуть хост, когда реферат пуст (адрес домашней страницы) </param>
/// <return> string </returns>
public String getReerer (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:/projects/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#? Если у вас есть вопросы, пожалуйста, свяжитесь со мной.