using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
public class RequestInfo : Page {
protected DataGrid grid;
public void LoadGrid(object sender, EventArgs e) {
HttpRequest req = Page.Request;
HttpBrowserCapabilities browser = req.Browser;
//----- set up a data table with 2 columns name "variable" and "value"
DataTable tab = new DataTable();
tab.Columns.Add(new DataColumn("variable", typeof(string)));
tab.Columns.Add(new DataColumn("value", typeof(string)));
//----- fill data table with information
DataRow row;
row = tab.NewRow();
row[0] = "UserHostName";
row[1] = req.UserHostName;
tab.Rows.Add(row);
row = tab.NewRow();
row[0] = "UserHostAddress";
row[1] = req.UserHostAddress;
tab.Rows.Add(row);
row = tab.NewRow();
row[0] = "HttpMethod";
row[1] = req.HttpMethod;
tab.Rows.Add(row);
row = tab.NewRow();
row[0] = "Browser name";
row[1] = browser.Browser;
tab.Rows.Add(row);
row = tab.NewRow();
row[0] = "Browser type";
row[1] = browser.Type;
tab.Rows.Add(row);
row = tab.NewRow();
row[0] = "Browser platform";
row[1] = browser.Platform;
tab.Rows.Add(row);
//----- bind the DataView of the data table to the grid
grid.DataSource = tab.DefaultView;
grid.DataBind();
}
}
|