Total members 11895 |It is currently Fri Dec 27, 2024 6:52 am Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





Here we are talking about HTTP headers sent to the by the browser to server side, we have control over this header information using request object, following code show header request information about the client used:
Code:
<%= Request.ServerVariables("HTTP_USER_AGENT")%>

This will print something like this:

This code demonstrates how to access the server variables collection using the "Request.ServerVariables" method. The "Request.ServerVariables" method is a built-in object in ASP that provides access to the server variables collection. The code snippet uses the "ALL_RAW" key to access the entire collection of server variables in their raw format. The "ALL_RAW" key is a predefined key that returns all the server variables in a single string, including headers, environment variables, and other information. The "Request.ServerVariables" method can be used to access a variety of information about the current request, including information about the client, the server, and the request itself. Some common examples of server variables include the client's IP address, the user agent, and the request method. It's worth noting that the "ALL_RAW" key is not recommended to be used in production as it could expose sensitive information about the server and the request, and also it could cause a security issue as well. It's also worth noting that, in general, it's not recommended to use the "Request.ServerVariables" method in production as it could cause security issues and it could also cause performance issues if it's used excessively. Overall, the code snippet provided uses the "Request.ServerVariables" method to access the entire collection of server variables in their raw format using the "ALL_RAW" key, but it's not recommended to use it in a production environment; it's essential to be aware of the security and performance implications when using the "Request.ServerVariables" method.



Mozilla/12.0 (Windows; U; Windows XP; en-US; rv:2.8.0.8) Gecko/20121121 Firefox/12
We can jump to printing all the header information without selecting one by one :
Code:
<%= Request.ServerVariables("ALL_RAW")%>

If you want to print header name:
Code:
<%= Request.ServerVariables("ALL_HTTP")%>

Out example one this is like this:
Code:

HTTP_ACCEPT
:*/* 
HTTP_ACCEPT_LANGUAGE:en-us 
HTTP_CONNECTION:Keep-Alive 
HTTP_HOST:127.0.0.1 
HTTP_REFERER:http://127.0.0.1/examples/request/ 
HTTP_USER_AGENT:Mozilla/12.0 (compatible; MSIE 8.0; Windows XP 5.1; Trident/4.0; GTB6.6; InfoPath.2; 
.NET CLR 2.1.4322; .NET CLR 3.0.50727; .NET CLR 4.0.4506.2152; .NET CLR 4.5.30729)



We can loop on all header variables like this :
We can display all the name value pairs for all the header information like this
Code:

Dim headerItem  
For Each headerItem  in Request
.ServerVariables 
Response
.Write "<b>" & headerItem  & "</b>:" 
Response
.Write Request.ServerVariables(headerItem) &  "<br/>"

Next




Certainly. The use of the "Request.ServerVariables" method in ASP provides access to a variety of information regarding the current request, including client information, server information, and information about the request itself. The server variables collection contains a wealth of information that can be useful for various purposes, such as logging, security, and performance. However, it's important to keep in mind that the use of the "Request.ServerVariables" method can have security and performance implications, particularly in production environments. Therefore, it's essential to handle the data retrieved from the server variables collection in a secure and efficient manner.

Regarding security, it's important to be aware that the server variables collection contains sensitive information, such as the client's IP address, the user agent, and the request method. This information should be handled carefully and only the necessary information should be used. Additionally, the data retrieved from the server variables collection should be validated and sanitized to prevent security issues such as cross-site scripting (XSS) and SQL injection. As for performance, it's important to note that the "Request.ServerVariables" method is considered a legacy method and it's not recommended for new developments due to its inefficiency. It's recommended to use the "Request.Headers" collection instead, which is more efficient and secure. Additionally, appropriate logging mechanisms should be employed to log the server variables data and to ensure that the data is handled in a secure manner. This will allow the developer to have a better understanding of the request, the client, and the server, and also it will help in case of any issue.

In conclusion, the use of the "Request.ServerVariables" method in ASP should be approached with caution, particularly in production environments. It's important to consider the security and performance implications, as well as the appropriate handling and validation of the data retrieved from the server variables collection. The use of the "Request.Headers" collection is recommended as an alternative for better efficiency and security.



_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : Usage of Request.ServerVariables object
 Object File Directives Usage PIC Assembly     -  
 Game code request     -  
 check request was GET or POST     -  
 JavaChat project request     -  
 request for apriori package     -  
 AJAX - Sending a request to a server     -  
 Request on Soa, SoapUI, Web services, SaaS     -  
 Get address of the page from which the request was made     -  
 Sending a post request using AJAX     -  
 Extracting Parameters from GET or POST Request     -  



Topic Tags

ASP Basics
cron





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com