4

Simple question but one i need to clarify for myself. In terms of collections that can be accessed in the request object there is:

Cookies:    (whats in  a text file in the browser)
Querystring:   (whats passed in the url like [key=value&key=value etc])
Server Variables:  ?
Form Variables:    ?

The ones with the ? next to are the ones that I dont really understand where in the http packet/html they are placed. I did a capture using wireshark:

POST /Security/HelixSessionAuth.aspx HTTP/1.0
Content-Type: application/x-www-form-urlencoded
Content-Length: 391

ClientIP=192.168.20.31
Url=%2Fflash%2F56553550%5Fhi%2Emp4
Log=SESSIONSTART%20%5B13%2FDec%2F2010%3A16%3A31%3A23%20%2B0000%5D%20%20flash%2F56553550%5Fhi%2Emp4%200%20192%2E168%2E20%2E31%203%20%5B13%2FDec%2F2010%3A16%3A31%3A23%20%2B0000%5D%200%200%200%20%5B0%20No%20Error%5D%20%5B0%20No%20Error%5D%20%5Brtmp%3A%2F%2Fhelix%2Epete%2Evideolibraryserver%2Ecom%2Fflash%2F56553550%5Fhi%2Emp4%5D%0A
HTTP/1.1 404 Not Found
Content-Type: text/html; charset=us-ascii
Server: Microsoft-HTTPAPI/2.0
Date: Mon, 13 Dec 2010 16:31:23 GMT
Connection: close
Content-Length: 315

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD><TITLE>Not Found</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
<BODY><h2>Not Found</h2>
<hr><p>HTTP Error 404. The requested resource is not found.</p>
</BODY></HTML>

Where abouts would they be in the above feed?

Oded
  • 489,969
  • 99
  • 883
  • 1,009
Exitos
  • 29,230
  • 38
  • 123
  • 178

3 Answers3

2

Wireshark for this is a bit of a sledgehammer-to-crack-a-nut, I'd suggest starting with the MSDN documentation for HttpRequest. This should help you understand what the Form and Server collections are and what they represent, then you'll know what you are looking for in the actual data packet.

Lazarus
  • 41,906
  • 4
  • 43
  • 54
  • @Joel Etherton : It wasn't the best analogy but I couldn't think of a better one ;) It may have been a sledgehammer in itself. Someone sniffing packets relating to a URL such as '/Security/HelixSessionAuth.aspx' and looking for where data is passed always leaves me a little concerned so I resort to advice rather than answers. – Lazarus Dec 14 '10 at 11:57
  • It also depends on the nut in question, the metaphorical problem or the one attached to the keyboard ;) – Lazarus Dec 14 '10 at 11:58
  • @Lazarus: I'd say if he's working in .Net and doesn't have a grasp of these 2 concepts, a little packet sniffing is the least of his worries. :) I +1 you for the link though for going back to basics. – Joel Etherton Dec 14 '10 at 12:01
  • haha yeah developer with +4 years experience guys guess I just never REALLY understood these things till I asked... – Exitos Dec 14 '10 at 13:47
2

The Form collection is the list of controls in the page that are passed to the action page via the POST method. Querystring is a GET, POST adds items to the Form collection. If you know the name of the control in the POST, you can access its value in the action page using:

Request.Form("myControl")

In .Net web forms, this is a little more complicated because .Net injects a specialized ClientID to preserve the ID of the actual control in the code behind.

The server collection is a collection of common server variables identifying information about the client, server, connection, browser, etc. A full list can be found here:

https://msdn.microsoft.com/en-us/library/ms524602(v=vs.90).aspx

Community
  • 1
  • 1
Joel Etherton
  • 37,325
  • 10
  • 89
  • 104
1

First about your tool. WireShark is a low level packet analysis tool which you don't need for learning HTTP concepts. Instead use Fiddler.

ServerVariables:

This is an old object from asp classic. Now there are many aliases for their objects. For example Request.UserHostAddress is an alias for Request.ServerVariables("remote_addr"). Also Headers, Cookies, Session objects, ... are available from this object. This object is there more of backward compatibility.

Form Variables:

All controls in ASP.NET are tracked with an ID by ASP.NET and their state is hold within ViewState hidden field. view state, is the technique used by an ASP.NET Web page to persist changes to the state of a Web Form across PostBacks. So, on every PostBack (form post, i.e click a button) ASP.NET at server side would repopulate form object and its children (controls inside the form) from post data. That's we call form collection.

Xaqron
  • 29,931
  • 42
  • 140
  • 205