ASP学习笔记(8)--Request对象相关

    OK,顾名思义,既然Response是server相应client的请求,那么Request就是server从client取其相关信息了。

    Request对象一共有5个集合,一个属性,一个方法,通常使用更多的是集合。下面就列出这5个集合。

    另,集合是存储字符串、数字、对象和其他值的地方。除了在存储或取出项目时集合会自动扩展与搜索外,集合与数组非常相近。与数组不同的是,集合被修改后,项目的位置将会移动。可以通过集合中项目的名称、索引或者通过在集合的所有项目中遍历访问项目。

    ClientCertificate--Request.ClientCertificate("key[filed]")客户端专门用于ssl的安全信息

   Cookies--Request.Cookies("cookiename")客户端保存的cookie的值

   Form--Request.Form("formname") 客户端通过html的form所发送的数值

   QueryString--Request.QueryString("keyname") 添加到url之后的名字/值对

   ServerVariables--Request.ServerVariables("veriablename") 在html头域的值

下面一个一个的看一下。

Form在前面的章节中已经有例子,现在看一下QueryString的例子。

<%@ language=javascript %>
<html>
 <head>
  <title>this is a test of querystring</title>
 </head>
 <body>
  <form action="fortest11.asp" method=post>
   <strong>input something as QueryString</strong><br>
   <input type=text name=querystringVar><br>
   <input type=submit value=submit>
  </form>
 </body>
</html>

fortest11.asp

<%@ language=javascript %>
<%
 var querystringVar=new String(Request.Form("querystringVar"))
%>
<html>
 <strong>the quarystring is:</strong> <% =querystringVar%><br>
 <a href="fortest11.asp?QueryString=<%=querystringVar%>">click here</a>
 to link to fortest11.asp?QueryString=<% =querystringVar%>
</html>

有两种方式来使用QueryString,第一是通过get从html的form中得到产生的QueryString串;或者直接手动添加一个QueryString并把他添加到url的最后,如上例。某些浏览器不支持自动转化为Unicode码,需要添加一个转化,就是escape()方法。

 var querystringVar=new String(Request.Form("querystringVar"))
 querystringVar=escape(querystringVar)

Request.Form和Request.QueryString都可以用简写方式,不过不推荐:Request("formName")Request("queryStringName")

接下来是ServerVariables。

ServerVariables表示client端发给服务器端的html 头域中的信息,有很多,如下所列:

引用  http://blog.ccw.com.cn/trackback.jsp?postID=8835

Syntax

Request.ServerVariables (server_variable)

ParameterDescription
server_variable Required. The name of the server variable to retrieve

Server Variables

VariableDescription
ALL_HTTPReturns all HTTP headers sent by the client. Always prefixed with HTTP_ and capitalized
ALL_RAWReturns all headers in raw form
APPL_MD_PATHReturns the meta base path for the application for the ISAPI DLL
APPL_PHYSICAL_PATHReturns the physical path corresponding to the meta base path
AUTH_PASSWORDReturns the value entered in the client's authentication dialog
AUTH_TYPEThe authentication method that the server uses to validate users
AUTH_USERReturns the raw authenticated user name
CERT_COOKIEReturns the unique ID for client certificate as a string
CERT_FLAGSbit0 is set to 1 if the client certificate is present and bit1 is set to 1 if the cCertification authority of the client certificate is not valid
CERT_ISSUERReturns the issuer field of the client certificate
CERT_KEYSIZEReturns the number of bits in Secure Sockets Layer connection key size
CERT_SECRETKEYSIZEReturns the number of bits in server certificate private key
CERT_SERIALNUMBERReturns the serial number field of the client certificate
CERT_SERVER_ISSUERReturns the issuer field of the server certificate
CERT_SERVER_SUBJECTReturns the subject field of the server certificate
CERT_SUBJECTReturns the subject field of the client certificate
CONTENT_LENGTHReturns the length of the content as sent by the client
CONTENT_TYPEReturns the data type of the content
GATEWAY_INTERFACEReturns the revision of the CGI specification used by the server
HTTP_<HeaderName>Returns the value stored in the header HeaderName
HTTP_ACCEPTReturns the value of the Accept header
HTTP_ACCEPT_LANGUAGEReturns a string describing the language to use for displaying content
HTTP_COOKIEReturns the cookie string included with the request
HTTP_REFERERReturns a string containing the URL of the page that referred the request to the current page using an <a> tag. If the page is redirected, HTTP_REFERER is empty
HTTP_USER_AGENTReturns a string describing the browser that sent the request
HTTPSReturns ON if the request came in through secure channel or OFF if the request came in through a non-secure channel
HTTPS_KEYSIZEReturns the number of bits in Secure Sockets Layer connection key size
HTTPS_SECRETKEYSIZEReturns the number of bits in server certificate private key
HTTPS_SERVER_ISSUERReturns the issuer field of the server certificate
HTTPS_SERVER_SUBJECTReturns the subject field of the server certificate
INSTANCE_IDThe ID for the IIS instance in text format
INSTANCE_META_PATHThe meta base path for the instance of IIS that responds to the request
LOCAL_ADDRReturns the server address on which the request came in
LOGON_USERReturns the Windows account that the user is logged into
PATH_INFOReturns extra path information as given by the client
PATH_TRANSLATEDA translated version of PATH_INFO that takes the path and performs any necessary virtual-to-physical mapping
QUERY_STRINGReturns the query information stored in the string following the question mark (?) in the HTTP request
REMOTE_ADDRReturns the IP address of the remote host making the request
REMOTE_HOSTReturns the name of the host making the request
REMOTE_USERReturns an unmapped user-name string sent in by the user
REQUEST_METHODReturns the method used to make the request
SCRIPT_NAMEReturns a virtual path to the script being executed
SERVER_NAMEReturns the server's host name, DNS alias, or IP address as it would appear in self-referencing URLs
SERVER_PORTReturns the port number to which the request was sent
SERVER_PORT_SECUREReturns a string that contains 0 or 1. If the request is being handled on the secure port, it will be 1. Otherwise, it will be 0
SERVER_PROTOCOLReturns the name and revision of the request information protocol
SERVER_SOFTWAREReturns the name and version of the server software that answers the request and runs the gateway
URLReturns the base portion of the URL

 

<%@ language=javascript %>
<HTML>
 <strong>ALL_RAW:</strong><br>
  <p><% =Request.ServerVariables("ALL_RAW") %></p>
 <strong>Remote host</strong><br>
  <p><%=Request.ServerVariables("REMOTE_HOST")%>
  </p>
</HTML>

Cookies还是用一节来学习吧。

Google
 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值