|
Hi,
I would like to make an application that monitors the Internet Information Server (IIS) and pushes the web pages requested by a specific IP address to another web page on the server machine. This would then enable an administrator sitting on the server machine to see the web pages that a specific client is watching in real time.
An ugly way to do this is to continuously monitor the IIS log file and push a new page to the administrator if the relevant IP address is seen in a new log entry.
I am however thinking of some alternatives:
1) Since it is not possible to delete the current log file, this may be due to it being kept open by a file stream run by a specific logging service (not sure here!). If this is so, is it possible to attach to this file stream and monitor it for specific key words (IP addresses)?
2) There must be an event triggered before writing to the log file. In that case, is there a way to intercept the event that writes to the log file and check for the IP address before it is written to file? (It would in fact be helpful to just know which event this is, as I could then just access the log file when necessary)
Thanks for any help or input!
|
|
|
|
|
If this is ASP.NET (I'm assuming, since you're in the C# forum!), why not just write an IHttpHandler or handle the HttpApplication.BeginRequest event (usually in the Global.asax file) to do the work? The IIS logs can grow to be very huge and must be immediately accessible or IIS could bomb-out. Also, the IIS logger uses a buffer technique where large blocks of the log are pre-allocated without anything being written to them (and are allocated ahead of time). You could use the FileSystemWatcher to watch for changes, but this wouldn't be assured to work since the IIS logger doesn't automatically flush the buffer (so it seems) in order to be more responsive.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Thanks for your input Heath! Unfortunately a large part of the web pages are not ASP.NET (this is in the C# forum due to me writing in C#), othwerwise your ideas would work well.
At least I now know some more about how the log files work, and see that it is not a good idea to use them. So I guess I'm back to square one...
|
|
|
|
|
There's always the old fashion way...so get (back?) into VC++ and write an ISAPI filter!
An ISAPI filter (if you don't know, or for all the kids out there...) is mapped into IIS and handles each request. Why, ASP.NET itself is an ISAPI filter (along with file type mappings to tell IIS to let ASP.NET handle a particular extension instead of it).
They aren't hard to write, but you definitely want to make sure you write good, robust code because these handle every request and run for the lifetime of IIS.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Hi,
There is a Label control and I want to change its FontStyle (Bold, Italic, ...) at Runtime. But Font.Bold and Font.Italic are read-only properties.
How can I do it?
regards,
Mehdi.
|
|
|
|
|
label1.Font = new Font(label1.Font, FontStyle.Bold);
or
label1.Font = new Font(label1.Font, FontStyle.Italic);
Roger Stewart
"I Owe, I Owe, it's off to work I go..."
|
|
|
|
|
I have class with certain properties, properties has certain attributes like DefaultValueAttribute ...now i have applied this attribute to one property...at runtime I want to change thie attribute meaning I want to change DefaultValueAttribute to some diff. value. How can I do it..?
- Atul Khalate
|
|
|
|
|
Sadly attributes can only be set at compile time
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
The attribute he's asking about in particular is only meaningful at design-time anyway, so it's unclear what he really wants.
-Blake
|
|
|
|
|
I'll ttry to clear my question here ...
I have defined one attribute,'GCDefaultValueAttribute',...which has one get/set property ,'Value',of type object.I have applied this attribute to property of class, 'Class1'.While applying attribute to this property I had passed some value (21)to the contructor of this attribute which will set the 'Value' property of GCDefaultValueAttribute. Now while loading an assembly in which this class is used,I want to change this default value from 21 to 26 for a class so that whenever new object created from this class it's property should have default value as 26 not 21 which was given at compile time.
Q1.Can I do it?
Q2.If "Yes" then How..?
Regards,
- Atul Khalate
|
|
|
|
|
I am leaving my current contract this week and I have documented my c# code to its eye teeth . But now they want a printed set of documentation so I have to print out the code comment report. Anyone know a good way of doing it ?
|
|
|
|
|
If you used the proper C# documentation syntax, you can use a popular project that I'm proud to be a part of called NDoc at http://ndoc.sourceforge.net[^]. This is widely used for C# projects by both major corporations and small projects alike. This can generate a CHM (for which the HTML Help view can print linear files) or other formats. A linear format is currently in beta stages but seems to work okay (just that the file is huge!). This won't use any internal comments, though, but I'm not sure if that's what you need.
Note: VS.NET has something similar but - as most people will agree - it's pretty basic and - to some extent - sucks.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Hi All!!
Well! I am developing a report designer like in Access but facing two problems.
1- I want to make my ToolBar Floating. So that my tools float over my designed area rather than making it fix on form.
2- on same designer I have to draw lines. when panel is repainted then all the lines disappear. SO i added them in an arraylist and repainted them all. But now whenever mouse is hovered over the panel all the lines start flickering.
Thanx in advance
sorry for my bad English.
|
|
|
|
|
Hi,
First of all, I'm new on CodeProject, so quick introducing: my names is Matthieu, I'm 26yo and live in France.
I start learning C# and I get stuck at the (easy?) following:
I have 2 string arrays, and I want to copy the first at the end of the second. I used Array.CopyTo method but it fails because the destination array is not large enough.
How can I increase the size of the dest string array ?
Thanks a lot for help,
Matthieu
|
|
|
|
|
Use Concat method of string.
s1= "Hello ";
s2 = "World"
s1 = s1.Concat(string2)
//s1 = Hello World
sorry for my bad English.
|
|
|
|
|
Thanks Itanium, but that's not what I want to do.
s1[0]="hello"
s1[1]="world"
s2[0]="good"
s2[1]="luck"
and I want to create a new string array like this:
s1[0]="hello"
s1[1]="world"
s1[2]="good"
s1[3]="luck"
Thanks a lot for help
Matthieu
|
|
|
|
|
you cannot re-dimension an array in C# like you could in VB with redim. You'll need to do something like:
string[] arrayOne = new string[]{"Hello", "World"};
string[] arrayTwo = new string[]{"Have", "a", "nice", "day"};
int newArrayLength = arrayOne.Length + arrayTwo.Length;
string[] arrayThree = arrayOne;
arrayOne = new String[newArrayLength];
int iterator = 0;
foreach(string s in arrayThree)
{
arrayOne[iterator] = s;
iterator++;
}
foreach(string s in arrayTwo)
{
arrayOne[iterator] = s;
iterator++;
}
I'm sure theres a more diginfied way, but it does work!!!
|
|
|
|
|
You've got two options here:
1. Create a new array of length= array1.length + array2.length, then use two consecutive Array.CopyTo() calls, one using zero as the index to start at, one using array1.length.
2. If you don't mind the minor performance hit from using a ICollection based object, take a look at System.Collections.ArrayList:
using System.Collections;
ArrayList array1 = new ArrayList();
array1.Add("hello");
array1.Add("world");
ArrayList array2 = new ArrayList();
array2.Add("Bonjour");
array2.Add("le monde");
array1.AddRange( array2 );
now array1 should contain (boxed as objects):
"hello",
"world",
"Bonjour",
"le monde"
Hope that helps...
Jeremy Kimball
|
|
|
|
|
I don't think that boxing takes place on strings, does it? Forgive me if I'm being dumb, as I have way more experience in Java than in .NET, but I believe that all strings are objects, aren't they? Class String extends/inherits from Object, not ValueType.
Also, the relative performance hit of using an ArrayList is not so minor in this case. I think that people should always program with performance in mind. Still, it's always nice to show people how to do things in different ways.
Regards,
Jeff Varszegi
|
|
|
|
|
Can any body guide me how to input password using VS.NET setup project, what i have seen is that there are text boxes which can take input but if i want to hide the text enterd in a password field i have no option. Presently what i am doing is that i have made a separate windows installer component which displays a modal dialog to input password, but it clearly seems something plugged into the setup and doesn't look like a part of setup when setup is run.
waiting for ur reply.
|
|
|
|
|
Can any body guide me how to input password using VS.NET setup project, what i have seen is that there are text boxes which can take input but if i want to hide the text enterd in a password field i have no option. Presently what i am doing is that i have made a separate windows installer component which displays a modal dialog to input password, but it clearly seems something plugged into the setup and doesn't look like a part of setup when setup is run.
waiting for ur reply.
|
|
|
|
|
The VS.NET setup project can't really be modified from what it supports. It's very basic. You should look into something like Wise Solutions for a real MSI development environment.
You could, however, add a new form (VS.NET has a fix number of fixed-layout forms) with a single text box then use a binary CustomAction to verify the password (almost like you are now) before proceding.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I have a Form.
Within the form's class, I have a method TestConnection which tries to establish a connection to a database, and returns a bool.
I invoke this method in the Form_Load method.
With regard to what TestConnection returned, I present the user with a messagebox asking whether to try again or not.
Since TestConnection takes a long time, I want to thread it, and once it completes, i want to check the returned bool and proceed.
What is the best way of threading it?
|
|
|
|
|
I'd do something like this:
public class MyThingy {
private bool testConnectionComplete = false;
private bool testConnectionResult = false;
....
public override void Form_Load(...) {
Thread tcStart = new Thread(new ThreadStart(this.TestConnection));
tcStart.Start();
Thread tcMonitor = new Thread(new ThreadStart(this.CheckTestConnection));
tcMonitor.Start();
}
public void TestConnection() {
this.testConnectionResult = WhateverYourResultIs;
this.testConnectionComplete = true;
}
public void CheckTestConnection() {
while( this.testConnectionComplete == false ) {
}
}
}
Of course, there may be better ways...
Jeremy Kimball
|
|
|
|
|
Do anyone know how to get back from the client the values of a data grid when columns have been added dinamically?
I noticed that if the AutoGenerateColumns flag is set to true and a dataset is binded to the DataGrid, postbacks include all the cells, even when the user changed values. This allows to add editing capabilities by traping the Update and Edit events.
However, if the columns are added dinamically (let's say template columns need to be used), no columns appear on the postback. See code below.
Notice that this part of the code
// BoundColumn pDBColumn = new BoundColumn();
// pDBColumn.DataField = "ARTIST";
// pDBColumn.HeaderText = "ARTIST2";
// DataGrid1.Columns.Add (pDBColumn);
adds a column dinamically. The column gets added to the response, but is missing on the client's request.
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace TemplateColumns
{
///
/// Summary description for WebForm1.
///
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label LblDebug;
protected System.Web.UI.WebControls.DataGrid DataGrid1;
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
if (!IsPostBack)
{
DataGridBind();
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.DataGrid1.EditCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGrid1_EditCommand);
this.DataGrid1.UpdateCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGrid1_UpdateCommand);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void DataGridBind()
{
// BoundColumn pDBColumn = new BoundColumn();
// pDBColumn.DataField = "ARTIST";
// pDBColumn.HeaderText = "ARTIST2";
// DataGrid1.Columns.Add (pDBColumn);
// Simple bind to a TextBox control
if (Session["TheDataset"] == null)
{
DataSet pDS0 = new DataSet("EmployeesDataSet");
pDS0.ReadXml(@"c:\cd_catalog.xml");
Session["TheDataset"] = pDS0;
}
DataSet pDS = Session["TheDataset"] as DataSet;
DataGrid1.DataSource = pDS;
DataGrid1.DataBind();
}
private void DataGrid1_EditCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
DataGrid1.SelectedIndex = e.Item.DataSetIndex;
DataGrid1.EditItemIndex = DataGrid1.SelectedIndex;
this.LblDebug.Text = "Cells on DataGrid1_EditCommand: " + e.Item.Cells.Count.ToString();
DataGridBind();
}
private void DataGrid1_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
this.LblDebug.Text = "Cells on DataGrid1_UpdateCommand: " + e.Item.Cells.Count.ToString();
DataGridBind();
}
}
}
|
|
|
|