Question

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?

Was it helpful?

Solution

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

OTHER TIPS

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.

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top