ASP get current path statement Daquan

Source: Internet
Author: User
In ASP development, you often need to use the path of the current page, which is relative, absolute, with parameters and without parameters. Here we will sort it out, I personally feel that ASP is very full about getting the page path statement, for example: request. servervariables script_name server_software File IP Path: <% = "http: //" & request. servervariables ("SERVER_NAME") & request. servervariables ("script_name") %> <br/>
Local IP address: <% = request. servervariables ("remote_addr") %> <br/>
Server Name: <% = request. servervariables ("SERVER_NAME") %> <br/>
Server IP address: <% = request. servervariables ("local_addr") %> <br/>
Server port: <% = request. servervariables ("server_port") %> <br/>
Server time: <% = now %> <br/>
IIS Version: <% = request. servervariables ("server_software") %> <br/>
Script Timeout: <% = server. scripttimeout %> <br/>
Path of this file: <% = server. mappath (request. servervariables ("script_name") %> <br/>
Server CPU usage: <% = request. servervariables ("number_of_processors") %> <br/>
Server interpretation engine: <% = scriptengine & "/" & scriptenginemajorversion & "." & scriptengineminorversion & "." & scriptenginebuildversion %> <br/>
Server Operating System: <% = request. servervariables ("OS") %> <br/>
Supported file types: <% = request. servervariables ("http_accept") %> <br/>
Path of the accessed file: <% = request. servervariables ("http_url") %> <br/>
User Agent Information: <% = request. servervariables ("http_user_agent") %> <br/>

get the file name in the URL and the passed value: request. servervariables ("script_name") + "? "+ Request. servervariables ("QUERY_STRING")

events
are generated as follows:
ip address path of this file: http: // localhost/Ceshi. ASP
local IP Address: 127.0.0.1
server name: localhost
Server IP Address: 127.0.0.1
server port: 8091
server time: 14:28:04
IIS Version: Microsoft-IIS/5.0
script Timeout: 90
path of this file: e: \ hospital \ Ceshi. ASP
server CPU quantity: 2
server interpretation engine: VBScript/5.6.7426
server operating system: windows_nt
supported file types: image/GIF, image/X-xbitmap, image/JPEG, image/pjpeg, application/vnd. MS-PowerPoint, application/vnd. MS-Excel, application/MSWord, application/X-Shockwave-flash, */*
file path:/Ceshi. ASP
User Agent Information: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; Maxthon; COM + 1.0.2204)

If you get the directory of this file, you can use the following functions:
<%
Public Function serverpath
Dim path
Dim POS
Path = "http: //" & request. servervariables ("SERVER_NAME") & request. servervariables ("script_name ")
Pos = Limit Rev (path ,"/")
Serverpath = left (path, POS)
End Function
%>
====================================< Br>
File directory: <% = serverpath %>
====================================< Br>

The running result is:
File directory: http: // localhost/=========================

Related Article

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.