PDA

View Full Version : Server Variables....


Tanker
07-24-2002, 10:09 PM
Does anyone have a list of the variables from the web server and what I can use to read them with asp?

I need to be able to pick out things like what port the web server is running on.

I tried a couple of searches but didn't turn anything up. Thanks in advance.

whammy
07-25-2002, 12:01 AM
I have no idea if this is an exhaustive list, but here's the ones I have handy:

Request.ServerVariables("ALL_HTTP")
Request.ServerVariables("AUTH_PASS"
Request.ServerVariables("AUTH_TYPE")
Request.ServerVariables("CONTENT_LENGTH")
Request.ServerVariables("CONTENT_TYPE")
Request.ServerVariables("GATEWAY_INTERFACE")
Request.ServerVariables("HTTP_ACCEPT_LANGUAGE")
Request.ServerVariables("HTTP_ACCEPT")
Request.ServerVariables("HTTP_CONNECTION")
Request.ServerVariables("HTTP_USER_AGENT")
Request.ServerVariables("HTTP_COOKIE")
Request.ServerVariables("HTTP_REFERER")
Request.ServerVariables("LOGON_ACCEPT_ENCODING")
Request.ServerVariables("LOGON_USER")
Request.ServerVariables("PATH_INFO")
Request.ServerVariables("PATH_TRANSLATED")
Request.ServerVariables("QUERY_STRING")
Request.ServerVariables("REMOTE_ADDR")
Request.ServerVariables("REMOTE_HOST")
Request.ServerVariables("REMOTE_IDENT")
Request.ServerVariables("REMOTE_USER")
Request.ServerVariables("REQUEST_BODY")
Request.ServerVariables("REQUEST_METHOD")
Request.ServerVariables("SCRIPT_MAP")
Request.ServerVariables("SCRIPT_NAME")
Request.ServerVariables("SERVER_NAME")
Request.ServerVariables("SERVER_PORT")
Request.ServerVariables("SERVER_PORT_SECURE")
Request.ServerVariables("SERVER_PROTOCOL")
Request.ServerVariables("SERVER_SOFTWARE")
Request.ServerVariables("URL")

glenngv
07-25-2002, 06:44 AM
shortcut and complete list version:

for each item in request.servervariables
response.write "<b>" & item & "</b> = " & request.servervariables(item) & "<br>"
next

Originally posted by whammy
I have no idea if this is an exhaustive list, but here's the ones I have handy:

Request.ServerVariables("ALL_HTTP")
Request.ServerVariables("AUTH_PASS"
Request.ServerVariables("AUTH_TYPE")
Request.ServerVariables("CONTENT_LENGTH")
Request.ServerVariables("CONTENT_TYPE")
Request.ServerVariables("GATEWAY_INTERFACE")
Request.ServerVariables("HTTP_ACCEPT_LANGUAGE")
Request.ServerVariables("HTTP_ACCEPT")
Request.ServerVariables("HTTP_CONNECTION")
Request.ServerVariables("HTTP_USER_AGENT")
Request.ServerVariables("HTTP_COOKIE")
Request.ServerVariables("HTTP_REFERER")
Request.ServerVariables("LOGON_ACCEPT_ENCODING")
Request.ServerVariables("LOGON_USER")
Request.ServerVariables("PATH_INFO")
Request.ServerVariables("PATH_TRANSLATED")
Request.ServerVariables("QUERY_STRING")
Request.ServerVariables("REMOTE_ADDR")
Request.ServerVariables("REMOTE_HOST")
Request.ServerVariables("REMOTE_IDENT")
Request.ServerVariables("REMOTE_USER")
Request.ServerVariables("REQUEST_BODY")
Request.ServerVariables("REQUEST_METHOD")
Request.ServerVariables("SCRIPT_MAP")
Request.ServerVariables("SCRIPT_NAME")
Request.ServerVariables("SERVER_NAME")
Request.ServerVariables("SERVER_PORT")
Request.ServerVariables("SERVER_PORT_SECURE")
Request.ServerVariables("SERVER_PROTOCOL")
Request.ServerVariables("SERVER_SOFTWARE")
Request.ServerVariables("URL")

webmarkart
07-25-2002, 07:37 AM
This site lists them and gives a description of what each one does... http://www.devguru.com/technologies/asp/quickref/request_servervariables.html

ReyN
07-25-2002, 02:16 PM
here's a demo that dynamically retrieves and displays the members of the thingy.

Enumerating the Request.ServerVariables Collection (http://aspalliance.com/aspxtreme/sys/Web/demos/requestservervariables.aspx) :D

whammy
07-25-2002, 11:38 PM
Very good answers, all. I should have thought of looping through the Request.ServerVariables collection, myself! :)

This is probably a good enough thread to stick to the top of the ASP forum.

Mhtml
07-26-2002, 05:01 AM
<%
For Each Item in Request.ServerVariables
Response.Write(Item & "<br />")
Next
%>

:eek: is that what the link was to?

ldiuf
07-26-2002, 06:47 PM
Hey WebMarkart, or anyone

On that link you provided it had these variables...


Request.ServerVariables("HTTP_UA_PIXELS") - a string detailing the screen resolution of the user agent.

Request.ServerVariables("HTTP_UA_COLOR") - a string with color information.

Request.ServerVariables("HTTP_UA_OS") - a string stating the operating system of the user agent.

Request.ServerVariables("HTTP_UA_CPU") - a string stating the processor type used by the user agent.


But they don't seem to work.
Does someone know how to get them to?

Cheers,
Larry:thumbsup:

Tanker
07-26-2002, 06:58 PM
Thank you all for the great responses. Helped immensely. Here is my cheat sheet if anyone else is interested. As for the color/pixel thing I don't see those listed when looping through the server vars.


<table border="1" width="1024">
<%
For Each Item in Request.ServerVariables
Response.Write("<tr><td noWrap>" & Item & "</td><td>" & Request.ServerVariables(Item) & "</tr>")
Next
%>
</table>


Thanks again...

Morgoth
07-27-2002, 04:01 PM
Originally posted by ldiuf
Hey WebMarkart, or anyone

On that link you provided it had these variables...


Request.ServerVariables("HTTP_UA_PIXELS") - a string detailing the screen resolution of the user agent.

Request.ServerVariables("HTTP_UA_COLOR") - a string with color information.

Request.ServerVariables("HTTP_UA_OS") - a string stating the operating system of the user agent.

Request.ServerVariables("HTTP_UA_CPU") - a string stating the processor type used by the user agent.


But they don't seem to work.
Does someone know how to get them to?

Cheers,
Larry:thumbsup:


I would also like to know.

Roy Sinclair
07-29-2002, 04:18 PM
Originally posted by ldiuf
Hey WebMarkart, or anyone

On that link you provided it had these variables...


Request.ServerVariables("HTTP_UA_PIXELS") - a string detailing the screen resolution of the user agent.

Request.ServerVariables("HTTP_UA_COLOR") - a string with color information.

Request.ServerVariables("HTTP_UA_OS") - a string stating the operating system of the user agent.

Request.ServerVariables("HTTP_UA_CPU") - a string stating the processor type used by the user agent.


But they don't seem to work.
Does someone know how to get them to?

Cheers,
Larry:thumbsup:

The key here is the letters "UA" in the middle of that list, that's short for User Agent and means those items will only show when the User Agent (ie the browser) provides those items. Checking with both IE 6 and Mozilla 1.0 none of those fields show up so it's probably safe to say you can't count on those fields.

Morgoth
07-29-2002, 11:31 PM
Why would they exsist if IE6.0 (Microsoft made) wouldn't support it?

I know other browsers do, or might, but common!


:rolleyes:

Roy Sinclair
07-30-2002, 06:37 PM
Originally posted by Morgoth
Why would they exsist if IE6.0 (Microsoft made) wouldn't support it?

I know other browsers do, or might, but common!


:rolleyes:

From the look of things they may be something that someone only started to implement and got shot down or were implemented in an early version of IE but was subsequently dropped. I see those items documented in only 4 MS Knowledgebase articles all of which are very old (two are from 1997, they probably relate to IE 2.0!). I suspect those items fell into the category of "more than the server should know about the user" as privacy concerns have mounted since the potential privacy abuses on the web have grown more apparent.

That's all speculation of course, it would take someone with a lot more time and patience than I have to try to fathom the mind of a company like MS.

Morgoth
07-31-2002, 01:21 PM
Originally posted by Roy Sinclair
I suspect those items fell into the category of "more than the server should know about the user" as privacy concerns have mounted since the potential privacy abuses on the web have grown more apparent.

It could be because people could easily not allow people with a different OS then the webmaster allows. And other reasons for the others.
But all I would like to know is the amount of colour the user can see, and the size of his screen so I know If i should resize my graphics and tables or what not.
Erg. I can always do some of this in Javascript, but I don't really wanna mix languages. I don't have any Javascript of my site. I'm going for Style tags and ASP, and it's working fine.

:) less languages to learn means easier work for creating a site that looks nice and I understand. / :)

bigtiger
10-25-2005, 08:32 AM
here's a demo that dynamically retrieves and displays the members of the thingy.

Enumerating the Request.ServerVariables Collection (http://aspalliance.com/aspxtreme/sys/Web/demos/requestservervariables.aspx) :D

hi, Reyn,

this is a version with C#, is this will have a javascript version?
coz i'am writring script with javascript.
thanks

agp,

glenngv
10-25-2005, 11:01 AM
Try this:
<%
for (var i in Request.ServerVariables){
Response.Write(i + "=" + Request.ServerVariables(i) + "<br />");
}
%>

bigtiger
10-25-2005, 03:48 PM
hi, glenngv:confused:
i'am sorry, this code do not work, i also tested with

function getServerInfo() {
var s="";
for(var k in Request.ServerVariables) {
k = new String(k);
s+= Request.ServerVariables(k);
}
return s;
}

thanks:)

glenngv
10-26-2005, 12:26 PM
What's happening? Is there an error? Or it just didn't go inside the for...in loop and returned an empty string?

You may also try JScript's Enumerator (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/jscript7/html/jsobjenumerator.asp) object.

nils123123
08-25-2010, 09:51 AM
There are many ways to do this.
If you want more explanation I found this resource useful, www.requestservervariables.com (http://www.requestservervariables.com/)

:thumbsup: