1. JavaScript
Die Codekopie lautet wie folgt:
/**
* Holen Sie sich den Referator der HTTP -Anforderung
* @ishost, ob der Host zurückgegeben werden soll, wenn der Boolesche Referater leer ist (die Adresse der Homepage)
*/
Funktion get_http_referer (isHost) {
if (isHost === undefined) {isHost = true; }
if (document.referrer) {
return document.referrer;
} anders {
if (isHost) {
return window.location.protocol + "//" + window.location.host;
} anders {
zurückkehren "";
}
}
}
2. C#
Die Codekopie lautet wie folgt:
/// <summary>
/// den HTTP -Anfragereferer erhalten
/// </summary>
/// <param name = "isHost"> ob der host zurückgibt, wenn referer leer ist (die Adresse der Homepage) </param>
/// <zurückgegeben> String </returns>
öffentliche String Getreferer (Bool IsHost)
{
if (request.urlreferrer! = null)
{
Rückgabeanforderung.urlreferrer.toString ();
}
anders
{
if (isHost)
{
Rückgabeanforderung.
}
anders
{
zurückkehren "";
}
}
}
3. Holen Sie sich verschiedene Teile der Anfrage -URL in C#
Website: http: // localhost: 1897/news/press/content.aspx/123? Id = 1#toc
Die Codekopie lautet wie folgt:
Request.ApplicationPath/
Request.physicalPathd: /projects/olution/web/news/press/content.aspx
System.io.path.getDirectoryName (Request.PhysicalPath) d:/projects/lösung/web/news/press
Request.PhysicalApplicationPathD:/Projects/Lösung/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
Anfrage.Pathinfo/123
Request.url.pathandArdQuery/news/press/content.aspx/123? Id = 1
Request.url.query? Id = 1
Request.url.fragment
Request.url.segmente/
Nachricht/
Drücken/
Content.aspx/
123
4..
//www.vevb.com/article/57407.htm
Wie wäre es damit? Haben Sie gelernt, den Referator der Seite in JavaScript und C#zu bekommen? Wenn Sie Fragen haben, kontaktieren Sie mich bitte.