Obtain the webservie request or the method that calls the page address

Source: Internet
Author: User
Tags baseuri

 

In fact, the method is the same as the method for obtaining the origin address of the page.

String strrequestfrom = "";
If (httpcontext. Current. Request. urlreferrer = NULL)
{
Strrequestfrom = "direct access ";
}
Else
{
Strrequestfrom = httpcontext. Current. Request. urlreferrer. absoluteuri;
}

Lazy writing using the three-object OPERATOR:

String strrequestfrom = httpcontext. Current. Request. urlreferrer = NULL? "Direct access": httpcontext. Current. Request. urlreferrer. absoluteuri;

Introduction to urlreferrer

Obtain information about the URL of the client's last request. The request is linked to the current URL.

Namespace: system. Web
ProgramSet: system. Web (in system. Web. dll)

Syntax
 
C #
Public URI urlreferrer {Get ;}
 

Attribute Value
A URI object.
Example
The followingCodeThe example shows the two property values that reference the client to the URL of the current application.

Uri myurl = request. urlreferrer;
Response. Write ("referrer URL port:" + server. htmlencode (myurl. Port. tostring () + "<br> ");
Response. Write ("referrer URL protocol:" + server. htmlencode (myurl. Scheme) + "<br> ");

Uri. absoluteuri Property

Obtain the absolute Uri.

Namespace: System
Assembly: system (in system. dll)

Syntax
 
C #
Public String absoluteuri {Get ;}
 

Attribute Value
String that contains the entire Uri.
Remarks
The absoluteuri attribute includes the entire URI stored in the URI instance, including all fragments and query strings.

Example
The following example outputs the complete content of the URI instance to the console. In the example, http://www.contoso.com/catalog/shownew.htm? Date = today will be output to the console.

C #
Uri baseuri = new uri ("http://www.contoso.com ");
Uri myuri = new uri (baseuri, "catalog/shownew.htm? Date = Today ");
Console. writeline (myuri. absoluteuri );

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.