Monitor Your Websites With Sound

by joey.westcott 24. February 2008 13:20
This weekend I had some fun messing around with the idea of monitoring one of my sites via sounds. All of the sites I run are .Net 2.0 or .Net 3.5, with that it allowed me to create a .Net solution that would work with any of my sites.

The idea started with a single thought of "boy it would be kinda neat to hear a sound when someone viewed a page in my site." So I spent all of 30 mins figuring out what i wanted to do create. I built a simple library for playing sounds based on a file or a path to a file. I then took the new lib and built a simple HttpModule for attaching to a site and tapping into begin request event.

This could be used for monitoring a few different sites along with a few different request types, not to mention that you could also include a different sound for events like, app start, begin request, end request, a request for .* file types (ie: if you wanted to know when someone downloaded one of your .rar files, you could just play a different sound file.) I'm sure that you could prob add a hundred more options to this list if you really wanted to.

Anyway I enjoyed hearing all the hits to my different sites this weekend and thought that you might like to as well.


sound playing lib.
namespace YetAnotherDeveloper.Common.SoundUtility
{

    public
sealed class Player
    {
        private
Player() { }

        public
static void PlaySound(string filePath)
        {
            SoundPlayer player =
new SoundPlayer();
            player.SoundLocation = filePath;
            player.Play();
        }

    }

}


simple http module example.
namespace YetAnotherDeveloper.HttpModules
{
    public
class PlaySoundModule : IHttpModule
    {
        public
void Dispose() { }  

        //Tap into the events.

        public
void Init(HttpApplication context)
        {
            context.BeginRequest += new EventHandler(context_BeginRequest);
         }

         void context_BeginRequest(object sender, EventArgs e)
        {
            YetAnotherDeveloper.Common.SoundUtility.Player.PlaySound(@"C:\Sounds\PageLoad.wav");
        }
    }
}


Modified webconfig to include this module in its pipeline.
<httpModules>
     <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    < add name="PlaySoundModule" type="YetAnotherDeveloper.HttpModules.PlaySoundModule, YetAnotherDeveloper.HttpModules"/>
</httpModules>

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , , ,

Development | .Net | Projects

Using C# to dynamically change virtual directories in IIS

by joey.westcott 22. November 2007 19:51

At work I have a need to change where a virtual direcorty is mapped in IIS.  So being the lazy developer that I am, I wrote a program that helps me take care of this.  Its a simple application that runs in the system tray and allows the remapping of the virtual directory with a couple of clicks.  I have created a page that I will try to keep updated when and if things change with it.  The source code should be posted by the end of the weekend if anyone desires to have a look at it.

This program will create and delete an IIS virtual directory as needed in C#.   

More details here Virtual Directory Manager

Currently rated 4.0 by 5 people

  • Currently 4/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: ,

Development | .Net | Projects

Powered by BlogEngine.NET 1.4.5.0
Theme by Mads Kristensen