<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>Tim - IIS</title>
    <link>http://blogs.thesitedoctor.co.uk/tim/</link>
    <description>Footprints in the snow of a warped mind</description>
    <language>en-gb</language>
    <copyright>Tim Gaunt</copyright>
    <lastBuildDate>Mon, 21 Feb 2011 08:07:07 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.2.8279.16125</generator>
    <managingEditor>timgaunt@gmail.com</managingEditor>
    <webMaster>timgaunt@gmail.com</webMaster>
    <item>
      <trackback:ping>http://blogs.thesitedoctor.co.uk/tim/Trackback.aspx?guid=3f30c3d6-7b7b-4efa-a561-106a9c12d207</trackback:ping>
      <pingback:server>http://blogs.thesitedoctor.co.uk/tim/pingback.aspx</pingback:server>
      <pingback:target>http://blogs.thesitedoctor.co.uk/tim/PermaLink,guid,3f30c3d6-7b7b-4efa-a561-106a9c12d207.aspx</pingback:target>
      <dc:creator>Tim</dc:creator>
      <wfw:comment>http://blogs.thesitedoctor.co.uk/tim/CommentView,guid,3f30c3d6-7b7b-4efa-a561-106a9c12d207.aspx</wfw:comment>
      <wfw:commentRss>http://blogs.thesitedoctor.co.uk/tim/SyndicationService.asmx/GetEntryCommentsRss?guid=3f30c3d6-7b7b-4efa-a561-106a9c12d207</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
We've recently been working on an inherited project that's got some interesting "features",
one of which is how they handle URL rewriting. 
</p>
        <p>
There are a number of HTTPHandlers that can be plugged into your application or ISAPI
filters to enable URL rewriting in IIS (and now routes in ASP.Net 4 etc) but a fairly
classic/old method was to handle it within your Global.asax's Application_BeginRequest
method.
</p>
        <h2>A Simple Example 
</h2>
        <p>
The example below rewrites a path such as "/article/123.aspx" and transforms it to
"/articledisplay.aspx?id=132"
</p>
        <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:f32c3428-b7e9-4f15-a8ea-c502c7ff2e88:b11f12a8-3155-470a-9fcd-d346eaa2bd30" class="wlWriterEditableSmartContent">
          <pre class="brush: c#;">&lt;%@ Application Language="C#" %&gt;
&lt;script RunAt="server"&gt;
    /// &lt;summary&gt;
    /// Begins the application request
    /// &lt;/summary&gt;
    /// &lt;param name="sender"&gt;The source of the event&lt;/param&gt;
    /// &lt;param name="e"&gt;A System.EventArgs that contains the event data&lt;/param&gt;
    void Application_BeginRequest(Object sender, EventArgs e)
    {
        // Get the current path (this will be an root relative link e.g. /article/123.aspx)
        string path = Request.Path.ToLower();

        // Work out if we want to transform it
        if (path.Contains("/article/"))
        {
            string id = path.Replace("/article/", String.Empty).Replace(".aspx", String.Empty);
            Context.RewritePath(String.Concat("~/articledisplay.aspx?id=", id), false);
        }
    }
&lt;/script&gt;</pre>
        </div>
        <p>
Ignoring the pro's and cons of using this method to rewrite the paths, one thing you
should be aware of is that Context.RewritePath <strong>does not</strong> end the code
execution.
</p>
        <h2>Why's that important to know?
</h2>
        <p>
The problem with this is simple, if you have additional rules later in the code, they
will also run -which could end up causing quite a lot of confusion.
</p>
        <p>
Consider the following example Application_BeginRequest method (overlook the semantics
of the code):
</p>
        <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:f32c3428-b7e9-4f15-a8ea-c502c7ff2e88:0479a46c-22cb-4cce-ab65-db4789acf4bb" class="wlWriterEditableSmartContent">
          <pre class="brush: c#;">// Get the current path (this will be an root relative link e.g. /category/123.aspx)
string path = Request.Path.ToLower();

// It's a category request
if (path.Contains("/category/"))
{
    // Use the id to perform some form of database lookup i.e. the category
    int id = Category.GetIdByUrl(path);

    // Redirect the user to the page to display the category
    Context.RewritePath(String.Concat("~/rewritepath.aspx?type=category&amp;id=", id), false);
}

// It's a product request
if (path.Contains("/product/"))
{
    string id = path.Replace("/product/", String.Empty).Replace(".aspx", String.Empty);

    // Redirect the user to the page to display the category
    Context.RewritePath(String.Concat("~/rewritepath.aspx?type=product&amp;id=", id), false);
}
</pre>
        </div>
        <p>
Now think about where the visitor would end up if they go to: /category/product/123.aspx
is it /rewritepath.aspx?type=category&amp;id=123 or /rewritepath.aspx?type=product&amp;id=123?
</p>
        <p>
Due to the way Context.RewritePath works, it executes /rewritepath.aspx?type=product&amp;id=123
so where's the issue?
</p>
        <p>
The problem is that although the pages behind it don't actually get executed until
the end of the Application_BeginRequest method, because the url satisfies both the
url rules, the database call will happen -even though in reality, it's not needed.
The result is that you could end up with a massive (and unnecessary) overhead to every
request hitting the ASP.Net engine (and if you have wildcard mapping enabled bare
in mind that's <strong>every</strong> request -including images/css/javascript).
</p>
        <p>
So if you feel the need to include additional rules (or additional processing e.g.
database calls), consider the order of your rules and return from the method as soon
as you know your rules are getting fulfilled, the above example would then be written
as:
</p>
        <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:f32c3428-b7e9-4f15-a8ea-c502c7ff2e88:f8897a7a-e6ac-4c34-9f3b-93c310e256a6" class="wlWriterEditableSmartContent">
          <pre class="brush: text;">// Get the current path (this will be an root relative link e.g. /category/123.aspx)
string path = Request.Path.ToLower();

// It's a product request
if (path.Contains("/product/"))
{
    string id = path.Replace("/product/", String.Empty).Replace(".aspx", String.Empty);

    // Redirect the user to the page to display the category
    Context.RewritePath(String.Concat("~/rewritepath.aspx?type=product&amp;id=", id), false);

    // We know that the user is going to the right place so no more rules need to be executed -return
    return;
}

// It's a category request
if (path.Contains("/category/"))
{
    // Use the id to perform some form of database lookup i.e. the category
    int id = Category.GetIdByUrl(path);

    // Redirect the user to the page to display the category
    Context.RewritePath(String.Concat("~/rewritepath.aspx?type=category&amp;id=", id), false);

    // There are no more rules so no need to return
}
</pre>
        </div>
        <h2>Other things to note
</h2>
        <p>
Using my somewhat simplistic example, there are a number of other things you could
do to improve the code's maintainability and performance:
</p>
        <ul>
          <li>
Consider using "StartsWith" instead of contains to make the match more specific (the
code we had used "IndexOf() != -1" throughout -but then also had a couple of "IndexOf()
== -1" to spice it up). There may be a minor overhead doing this however it makes
it a lot easier to understand what you want to achieve.</li>
          <li>
Try not to do anything other than "forward" the request on as quickly as possible
i.e. no database calls! 
</li>
          <li>
Add known exclusions at the start of the code where you know you don't need to rewrite
the path i.e. the folders for CSS, images and JavaScript. You could also approach
this by wrapping all rules in an inclusion i.e. if(path.StartsWith("category") ||
path.StartsWith("product")) 
</li>
          <li>
You should write the rules not only in order of importance/process but while doing
so, give consideration to which will be processed most frequently e.g. if you have
a rule that's only use by 1 in 1000 calls as the first rule, this will be checked
before the relevant rules 999 times in 1000 -so what may be a very small overhead
could become a large bottleneck as soon as your site starts to grow in popularity 
</li>
          <li>
Document each rule clearly i.e. explaining what url formats should trigger it 
</li>
          <li>
Where rules are mutually exclusive, use "else if" rather than just "if" to make it
clear that you don't expect the others to be run if the first is valid. 
</li>
        </ul>
        <img width="0" height="0" src="http://blogs.thesitedoctor.co.uk/tim/aggbug.ashx?id=3f30c3d6-7b7b-4efa-a561-106a9c12d207" />
      </body>
      <title>Beware! Context.RewritePath does not end the current execution path</title>
      <guid isPermaLink="false">http://blogs.thesitedoctor.co.uk/tim/PermaLink,guid,3f30c3d6-7b7b-4efa-a561-106a9c12d207.aspx</guid>
      <link>http://blogs.thesitedoctor.co.uk/tim/2011/02/21/Beware+ContextRewritePath+Does+Not+End+The+Current+Execution+Path.aspx</link>
      <pubDate>Mon, 21 Feb 2011 08:07:07 GMT</pubDate>
      <description>&lt;p&gt;
We've recently been working on an inherited project that's got some interesting "features",
one of which is how they handle URL rewriting. 
&lt;/p&gt;
&lt;p&gt;
There are a number of HTTPHandlers that can be plugged into your application or ISAPI
filters to enable URL rewriting in IIS (and now routes in ASP.Net 4 etc) but a fairly
classic/old method was to handle it within your Global.asax's Application_BeginRequest
method.
&lt;/p&gt;
&lt;h2&gt;A Simple Example 
&lt;/h2&gt;
&lt;p&gt;
The example below rewrites a path such as "/article/123.aspx" and transforms it to
"/articledisplay.aspx?id=132"
&lt;/p&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:f32c3428-b7e9-4f15-a8ea-c502c7ff2e88:b11f12a8-3155-470a-9fcd-d346eaa2bd30" class="wlWriterEditableSmartContent"&gt;&lt;pre class="brush: c#;"&gt;&amp;lt;%@ Application Language="C#" %&amp;gt;
&amp;lt;script RunAt="server"&amp;gt;
    /// &amp;lt;summary&amp;gt;
    /// Begins the application request
    /// &amp;lt;/summary&amp;gt;
    /// &amp;lt;param name="sender"&amp;gt;The source of the event&amp;lt;/param&amp;gt;
    /// &amp;lt;param name="e"&amp;gt;A System.EventArgs that contains the event data&amp;lt;/param&amp;gt;
    void Application_BeginRequest(Object sender, EventArgs e)
    {
        // Get the current path (this will be an root relative link e.g. /article/123.aspx)
        string path = Request.Path.ToLower();

        // Work out if we want to transform it
        if (path.Contains("/article/"))
        {
            string id = path.Replace("/article/", String.Empty).Replace(".aspx", String.Empty);
            Context.RewritePath(String.Concat("~/articledisplay.aspx?id=", id), false);
        }
    }
&amp;lt;/script&amp;gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;
Ignoring the pro's and cons of using this method to rewrite the paths, one thing you
should be aware of is that Context.RewritePath &lt;strong&gt;does not&lt;/strong&gt; end the code
execution.
&lt;/p&gt;
&lt;h2&gt;Why's that important to know?
&lt;/h2&gt;
&lt;p&gt;
The problem with this is simple, if you have additional rules later in the code, they
will also run -which could end up causing quite a lot of confusion.
&lt;/p&gt;
&lt;p&gt;
Consider the following example Application_BeginRequest method (overlook the semantics
of the code):
&lt;/p&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:f32c3428-b7e9-4f15-a8ea-c502c7ff2e88:0479a46c-22cb-4cce-ab65-db4789acf4bb" class="wlWriterEditableSmartContent"&gt;&lt;pre class="brush: c#;"&gt;// Get the current path (this will be an root relative link e.g. /category/123.aspx)
string path = Request.Path.ToLower();

// It's a category request
if (path.Contains("/category/"))
{
    // Use the id to perform some form of database lookup i.e. the category
    int id = Category.GetIdByUrl(path);

    // Redirect the user to the page to display the category
    Context.RewritePath(String.Concat("~/rewritepath.aspx?type=category&amp;amp;id=", id), false);
}

// It's a product request
if (path.Contains("/product/"))
{
    string id = path.Replace("/product/", String.Empty).Replace(".aspx", String.Empty);

    // Redirect the user to the page to display the category
    Context.RewritePath(String.Concat("~/rewritepath.aspx?type=product&amp;amp;id=", id), false);
}
&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;
Now think about where the visitor would end up if they go to: /category/product/123.aspx
is it /rewritepath.aspx?type=category&amp;amp;id=123 or /rewritepath.aspx?type=product&amp;amp;id=123?
&lt;/p&gt;
&lt;p&gt;
Due to the way Context.RewritePath works, it executes /rewritepath.aspx?type=product&amp;amp;id=123
so where's the issue?
&lt;/p&gt;
&lt;p&gt;
The problem is that although the pages behind it don't actually get executed until
the end of the Application_BeginRequest method, because the url satisfies both the
url rules, the database call will happen -even though in reality, it's not needed.
The result is that you could end up with a massive (and unnecessary) overhead to every
request hitting the ASP.Net engine (and if you have wildcard mapping enabled bare
in mind that's &lt;strong&gt;every&lt;/strong&gt; request -including images/css/javascript).
&lt;/p&gt;
&lt;p&gt;
So if you feel the need to include additional rules (or additional processing e.g.
database calls), consider the order of your rules and return from the method as soon
as you know your rules are getting fulfilled, the above example would then be written
as:
&lt;/p&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:f32c3428-b7e9-4f15-a8ea-c502c7ff2e88:f8897a7a-e6ac-4c34-9f3b-93c310e256a6" class="wlWriterEditableSmartContent"&gt;&lt;pre class="brush: text;"&gt;// Get the current path (this will be an root relative link e.g. /category/123.aspx)
string path = Request.Path.ToLower();

// It's a product request
if (path.Contains("/product/"))
{
    string id = path.Replace("/product/", String.Empty).Replace(".aspx", String.Empty);

    // Redirect the user to the page to display the category
    Context.RewritePath(String.Concat("~/rewritepath.aspx?type=product&amp;amp;id=", id), false);

    // We know that the user is going to the right place so no more rules need to be executed -return
    return;
}

// It's a category request
if (path.Contains("/category/"))
{
    // Use the id to perform some form of database lookup i.e. the category
    int id = Category.GetIdByUrl(path);

    // Redirect the user to the page to display the category
    Context.RewritePath(String.Concat("~/rewritepath.aspx?type=category&amp;amp;id=", id), false);

    // There are no more rules so no need to return
}
&lt;/pre&gt;
&lt;/div&gt;
&lt;h2&gt;Other things to note
&lt;/h2&gt;
&lt;p&gt;
Using my somewhat simplistic example, there are a number of other things you could
do to improve the code's maintainability and performance:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
Consider using "StartsWith" instead of contains to make the match more specific (the
code we had used "IndexOf() != -1" throughout -but then also had a couple of "IndexOf()
== -1" to spice it up). There may be a minor overhead doing this however it makes
it a lot easier to understand what you want to achieve.&lt;/li&gt;
&lt;li&gt;
Try not to do anything other than "forward" the request on as quickly as possible
i.e. no database calls! 
&lt;/li&gt;
&lt;li&gt;
Add known exclusions at the start of the code where you know you don't need to rewrite
the path i.e. the folders for CSS, images and JavaScript. You could also approach
this by wrapping all rules in an inclusion i.e. if(path.StartsWith("category") ||
path.StartsWith("product")) 
&lt;/li&gt;
&lt;li&gt;
You should write the rules not only in order of importance/process but while doing
so, give consideration to which will be processed most frequently e.g. if you have
a rule that's only use by 1 in 1000 calls as the first rule, this will be checked
before the relevant rules 999 times in 1000 -so what may be a very small overhead
could become a large bottleneck as soon as your site starts to grow in popularity 
&lt;/li&gt;
&lt;li&gt;
Document each rule clearly i.e. explaining what url formats should trigger it 
&lt;/li&gt;
&lt;li&gt;
Where rules are mutually exclusive, use "else if" rather than just "if" to make it
clear that you don't expect the others to be run if the first is valid. 
&lt;/li&gt;
&lt;/ul&gt;
&lt;img width="0" height="0" src="http://blogs.thesitedoctor.co.uk/tim/aggbug.ashx?id=3f30c3d6-7b7b-4efa-a561-106a9c12d207" /&gt;</description>
      <comments>http://blogs.thesitedoctor.co.uk/tim/CommentView,guid,3f30c3d6-7b7b-4efa-a561-106a9c12d207.aspx</comments>
      <category>ASP.Net</category>
      <category>C#</category>
      <category>Code Management</category>
      <category>IIS</category>
      <category>The Site Doctor</category>
    </item>
    <item>
      <trackback:ping>http://blogs.thesitedoctor.co.uk/tim/Trackback.aspx?guid=6032d67e-2a61-47cc-8b8d-1b6a9f60efd6</trackback:ping>
      <pingback:server>http://blogs.thesitedoctor.co.uk/tim/pingback.aspx</pingback:server>
      <pingback:target>http://blogs.thesitedoctor.co.uk/tim/PermaLink,guid,6032d67e-2a61-47cc-8b8d-1b6a9f60efd6.aspx</pingback:target>
      <dc:creator>Tim</dc:creator>
      <wfw:comment>http://blogs.thesitedoctor.co.uk/tim/CommentView,guid,6032d67e-2a61-47cc-8b8d-1b6a9f60efd6.aspx</wfw:comment>
      <wfw:commentRss>http://blogs.thesitedoctor.co.uk/tim/SyndicationService.asmx/GetEntryCommentsRss?guid=6032d67e-2a61-47cc-8b8d-1b6a9f60efd6</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <img style="display: inline" align="right" src="http://www.diaryofaninja.com/asset/blogimages/email-error-missing_c2399bc2-ad89-45be-944c-d756bee14e5d.jpg" width="200" height="159" />Simple
tip this afternoon. You may have got the following error when sending emails through
ASP.Net’s built in mail server before:
</p>
        <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:f32c3428-b7e9-4f15-a8ea-c502c7ff2e88:a48ce551-36f0-4887-a68f-6c18b5822944" class="wlWriterSmartContent">
          <pre class="brush: text;">From: postmaster@YourWebserversName [mailto:postmaster@YourWebserversName] 
Sent: 25 June 2010 13:22
To: sender@sendingdomainname.com
Subject: Delivery Status Notification (Failure)

This is an automatically generated Delivery Status Notification.

Delivery to the following recipients failed.

      recipient@recievingdomainname.com

Reporting-MTA: dns;YourWebserversName
Received-From-MTA: dns;YourWebserversName
Arrival-Date: Fri, 25 Jun 2010 13:21:30 +0100

Final-Recipient: rfc822;recipient@recievingdomainname.com
Action: failed
Status: 5.5.0
Diagnostic-Code: smtp;504 &lt;YourWebserversName&gt;: Helo command rejected: need fully-qualified hostname</pre>
        </div>
        <br />
        <p>
 
</p>
        <p>
The fix is easy:
</p>
        <ol>
          <li>
Open IIS</li>
          <li>
View the properties of you Default SMTP Virtual Server</li>
          <li>
Go to the “Delivery” tab</li>
          <li>
Click the “Advanced” button (in the bottom right corner)</li>
          <li>
Under “Fully-qualified domain name” enter a domain name that points to the server</li>
          <li>
Click Ok until you’re back to IIS</li>
        </ol>
        <img width="0" height="0" src="http://blogs.thesitedoctor.co.uk/tim/aggbug.ashx?id=6032d67e-2a61-47cc-8b8d-1b6a9f60efd6" />
      </body>
      <title>Helo command rejected: need fully-qualified hostname when sending emails</title>
      <guid isPermaLink="false">http://blogs.thesitedoctor.co.uk/tim/PermaLink,guid,6032d67e-2a61-47cc-8b8d-1b6a9f60efd6.aspx</guid>
      <link>http://blogs.thesitedoctor.co.uk/tim/2010/06/30/Helo+Command+Rejected+Need+Fullyqualified+Hostname+When+Sending+Emails.aspx</link>
      <pubDate>Wed, 30 Jun 2010 15:20:08 GMT</pubDate>
      <description>&lt;p&gt;
&lt;img style="display: inline" align="right" src="http://www.diaryofaninja.com/asset/blogimages/email-error-missing_c2399bc2-ad89-45be-944c-d756bee14e5d.jpg" width="200" height="159"&gt;Simple
tip this afternoon. You may have got the following error when sending emails through
ASP.Net’s built in mail server before:
&lt;/p&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:f32c3428-b7e9-4f15-a8ea-c502c7ff2e88:a48ce551-36f0-4887-a68f-6c18b5822944" class="wlWriterSmartContent"&gt;&lt;pre class="brush: text;"&gt;From: postmaster@YourWebserversName [mailto:postmaster@YourWebserversName] 
Sent: 25 June 2010 13:22
To: sender@sendingdomainname.com
Subject: Delivery Status Notification (Failure)

This is an automatically generated Delivery Status Notification.

Delivery to the following recipients failed.

      recipient@recievingdomainname.com

Reporting-MTA: dns;YourWebserversName
Received-From-MTA: dns;YourWebserversName
Arrival-Date: Fri, 25 Jun 2010 13:21:30 +0100

Final-Recipient: rfc822;recipient@recievingdomainname.com
Action: failed
Status: 5.5.0
Diagnostic-Code: smtp;504 &amp;lt;YourWebserversName&amp;gt;: Helo command rejected: need fully-qualified hostname&lt;/pre&gt;
&lt;/div&gt;
&lt;br&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
The fix is easy:
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
Open IIS&lt;/li&gt;
&lt;li&gt;
View the properties of you Default SMTP Virtual Server&lt;/li&gt;
&lt;li&gt;
Go to the “Delivery” tab&lt;/li&gt;
&lt;li&gt;
Click the “Advanced” button (in the bottom right corner)&lt;/li&gt;
&lt;li&gt;
Under “Fully-qualified domain name” enter a domain name that points to the server&lt;/li&gt;
&lt;li&gt;
Click Ok until you’re back to IIS&lt;/li&gt;
&lt;/ol&gt;
&lt;img width="0" height="0" src="http://blogs.thesitedoctor.co.uk/tim/aggbug.ashx?id=6032d67e-2a61-47cc-8b8d-1b6a9f60efd6" /&gt;</description>
      <comments>http://blogs.thesitedoctor.co.uk/tim/CommentView,guid,6032d67e-2a61-47cc-8b8d-1b6a9f60efd6.aspx</comments>
      <category>ASP.Net</category>
      <category>IIS</category>
      <category>The Site Doctor</category>
    </item>
    <item>
      <trackback:ping>http://blogs.thesitedoctor.co.uk/tim/Trackback.aspx?guid=646bc72f-3ad7-42c4-904b-dc18c1eff695</trackback:ping>
      <pingback:server>http://blogs.thesitedoctor.co.uk/tim/pingback.aspx</pingback:server>
      <pingback:target>http://blogs.thesitedoctor.co.uk/tim/PermaLink,guid,646bc72f-3ad7-42c4-904b-dc18c1eff695.aspx</pingback:target>
      <dc:creator>Tim</dc:creator>
      <wfw:comment>http://blogs.thesitedoctor.co.uk/tim/CommentView,guid,646bc72f-3ad7-42c4-904b-dc18c1eff695.aspx</wfw:comment>
      <wfw:commentRss>http://blogs.thesitedoctor.co.uk/tim/SyndicationService.asmx/GetEntryCommentsRss?guid=646bc72f-3ad7-42c4-904b-dc18c1eff695</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; margin-left: 0px; border-left-width: 0px; margin-right: 0px" title="powershell2xa4[1]" border="0" alt="powershell2xa4[1]" align="right" src="http://blogs.thesitedoctor.co.uk/tim/images/SetUmbracoFolderPermissionswithPowershel_C08E/powershell2xa41.jpg" width="260" height="208" /> If
you're not configuring Umbraco through a web installer, you've had your installs in
place for years and never checked the permissions or whoever set the permissions up
was lazy and gave IIS write access to the entire folder, there will come a time when
you want to restrict modify access to just those user(s) who should have access.
</p>
        <p>
You can find a (pretty) complete <a href="http://umbraco.org/documentation/books/important-files-and-folder-structure/permissions">list
of the files/folders that the Umbraco install should have access to here</a> but assigning
them across 101 different installs is a 
<abbr title="Pain In The Ass">
PITA
</abbr>
. Thanks to a <a href="http://www.powershell.nu/2009/02/13/set-folder-permissions-using-a-powershell-script/">helpful
PowerShell script to set folder permissions from PowerShell.nu</a> you can easily
automate the process.
</p>
        <p>
For those of you not familiar with PowerShell (like me) complete instructions are
below. For the rest, here's the command: 
</p>
        <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:f32c3428-b7e9-4f15-a8ea-c502c7ff2e88:6204aace-8f3a-49eb-928d-e0c33f5a299b" class="wlWriterEditableSmartContent">
          <pre class="brush: powershell;">Get-ChildItem -path ##PATH TO YOUR INSTALL## 
| Where { $_.name -eq "Bin" -or $_.name -eq "Config" -or $_.name -eq "Css" -or $_.name -eq "Data" -or $_.name -eq "Masterpages" -or $_.name -eq "Media" -or $_.name -eq "Scripts" -or $_.name -eq "Umbraco" -or $_.name -eq "Umbraco_client" -or $_.name -eq "UserControls" -or $_.name -eq "Xslt" } 
| ForEach {./SetFolderPermission.ps1 -path $_.Fullname -Access "NETWORK SERVICE" -Permission Modify}
</pre>
        </div>
        <p>
 
</p>
        <p>
          <strong>Instructions:</strong>
        </p>
        <ol>
          <li>
Save the <a href="http://blogs.thesitedoctor.co.uk/tim/files/setfolderpermission.ps1.txt">SetFolderPermission.ps1
script</a> to your server 
</li>
          <li>
Open your PowerShell console (I think it's installed by default if not, you can <a href="http://www.microsoft.com/windowsserver2003/technologies/management/powershell/default.mspx">download
PowerShell here</a>) 
</li>
          <li>
Copy the above PowerShell command into notepad 
</li>
          <li>
Update "##PATH TO YOUR INSTALL##" to your Umbraco install 
</li>
          <li>
If your IIS install doesn't use NETWORK SERVICE as the default user, update it to
your user 
</li>
          <li>
Make sure it's all on a single line 
</li>
          <li>
Copy/Paste/Run in PowerShell 
</li>
        </ol>
        <p>
          <strong>Bonus</strong>
        </p>
        <p>
If you're uber lazy and just have a web folder of Umbraco installs you can set the
path to the folder of Umbraco installs and use:
</p>
        <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:f32c3428-b7e9-4f15-a8ea-c502c7ff2e88:759a61db-2bc9-456c-9e1b-240acdea1c26" class="wlWriterEditableSmartContent">
          <pre class="brush: text;">Get-ChildItem -path ##PATH TO YOUR FOLDER## -recurse
| Where { $_.name -eq "Bin" -or $_.name -eq "Config" -or $_.name -eq "Css" -or $_.name -eq "Data" -or $_.name -eq "Masterpages" -or $_.name -eq "Media" -or $_.name -eq "Scripts" -or $_.name -eq "Umbraco" -or $_.name -eq "Umbraco_client" -or $_.name -eq "UserControls" -or $_.name -eq "Xslt" } 
| ForEach {./SetFolderPermission.ps1 -path $_.Fullname -Access "NETWORK SERVICE" -Permission Modify}
</pre>
        </div>
        <p>
 
</p>
        <p>
I've not tried this mind you and can't recommend it but hey, it's there if you want
it ;)
</p>
        <img width="0" height="0" src="http://blogs.thesitedoctor.co.uk/tim/aggbug.ashx?id=646bc72f-3ad7-42c4-904b-dc18c1eff695" />
      </body>
      <title>Set Umbraco Folder Permissions with Powershell</title>
      <guid isPermaLink="false">http://blogs.thesitedoctor.co.uk/tim/PermaLink,guid,646bc72f-3ad7-42c4-904b-dc18c1eff695.aspx</guid>
      <link>http://blogs.thesitedoctor.co.uk/tim/2010/06/17/Set+Umbraco+Folder+Permissions+With+Powershell.aspx</link>
      <pubDate>Thu, 17 Jun 2010 13:47:22 GMT</pubDate>
      <description>&lt;p&gt;
&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; margin-left: 0px; border-left-width: 0px; margin-right: 0px" title="powershell2xa4[1]" border="0" alt="powershell2xa4[1]" align="right" src="http://blogs.thesitedoctor.co.uk/tim/images/SetUmbracoFolderPermissionswithPowershel_C08E/powershell2xa41.jpg" width="260" height="208" /&gt; If
you're not configuring Umbraco through a web installer, you've had your installs in
place for years and never checked the permissions or whoever set the permissions up
was lazy and gave IIS write access to the entire folder, there will come a time when
you want to restrict modify access to just those user(s) who should have access.
&lt;/p&gt;
&lt;p&gt;
You can find a (pretty) complete &lt;a href="http://umbraco.org/documentation/books/important-files-and-folder-structure/permissions"&gt;list
of the files/folders that the Umbraco install should have access to here&lt;/a&gt; but assigning
them across 101 different installs is a 
&lt;abbr title="Pain In The Ass"&gt;
PITA
&lt;/abbr&gt;
. Thanks to a &lt;a href="http://www.powershell.nu/2009/02/13/set-folder-permissions-using-a-powershell-script/"&gt;helpful
PowerShell script to set folder permissions from PowerShell.nu&lt;/a&gt; you can easily
automate the process.
&lt;/p&gt;
&lt;p&gt;
For those of you not familiar with PowerShell (like me) complete instructions are
below. For the rest, here's the command: 
&lt;/p&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:f32c3428-b7e9-4f15-a8ea-c502c7ff2e88:6204aace-8f3a-49eb-928d-e0c33f5a299b" class="wlWriterEditableSmartContent"&gt;&lt;pre class="brush: powershell;"&gt;Get-ChildItem -path ##PATH TO YOUR INSTALL## 
| Where { $_.name -eq "Bin" -or $_.name -eq "Config" -or $_.name -eq "Css" -or $_.name -eq "Data" -or $_.name -eq "Masterpages" -or $_.name -eq "Media" -or $_.name -eq "Scripts" -or $_.name -eq "Umbraco" -or $_.name -eq "Umbraco_client" -or $_.name -eq "UserControls" -or $_.name -eq "Xslt" } 
| ForEach {./SetFolderPermission.ps1 -path $_.Fullname -Access "NETWORK SERVICE" -Permission Modify}
&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;
&amp;#160;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Instructions:&lt;/strong&gt;
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
Save the &lt;a href="http://blogs.thesitedoctor.co.uk/tim/files/setfolderpermission.ps1.txt"&gt;SetFolderPermission.ps1
script&lt;/a&gt; to your server 
&lt;/li&gt;
&lt;li&gt;
Open your PowerShell console (I think it's installed by default if not, you can &lt;a href="http://www.microsoft.com/windowsserver2003/technologies/management/powershell/default.mspx"&gt;download
PowerShell here&lt;/a&gt;) 
&lt;/li&gt;
&lt;li&gt;
Copy the above PowerShell command into notepad 
&lt;/li&gt;
&lt;li&gt;
Update "##PATH TO YOUR INSTALL##" to your Umbraco install 
&lt;/li&gt;
&lt;li&gt;
If your IIS install doesn't use NETWORK SERVICE as the default user, update it to
your user 
&lt;/li&gt;
&lt;li&gt;
Make sure it's all on a single line 
&lt;/li&gt;
&lt;li&gt;
Copy/Paste/Run in PowerShell 
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
&lt;strong&gt;Bonus&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
If you're uber lazy and just have a web folder of Umbraco installs you can set the
path to the folder of Umbraco installs and use:
&lt;/p&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:f32c3428-b7e9-4f15-a8ea-c502c7ff2e88:759a61db-2bc9-456c-9e1b-240acdea1c26" class="wlWriterEditableSmartContent"&gt;&lt;pre class="brush: text;"&gt;Get-ChildItem -path ##PATH TO YOUR FOLDER## -recurse
| Where { $_.name -eq "Bin" -or $_.name -eq "Config" -or $_.name -eq "Css" -or $_.name -eq "Data" -or $_.name -eq "Masterpages" -or $_.name -eq "Media" -or $_.name -eq "Scripts" -or $_.name -eq "Umbraco" -or $_.name -eq "Umbraco_client" -or $_.name -eq "UserControls" -or $_.name -eq "Xslt" } 
| ForEach {./SetFolderPermission.ps1 -path $_.Fullname -Access "NETWORK SERVICE" -Permission Modify}
&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;
&amp;#160;
&lt;/p&gt;
&lt;p&gt;
I've not tried this mind you and can't recommend it but hey, it's there if you want
it ;)
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blogs.thesitedoctor.co.uk/tim/aggbug.ashx?id=646bc72f-3ad7-42c4-904b-dc18c1eff695" /&gt;</description>
      <comments>http://blogs.thesitedoctor.co.uk/tim/CommentView,guid,646bc72f-3ad7-42c4-904b-dc18c1eff695.aspx</comments>
      <category>ASP.Net</category>
      <category>Hosting</category>
      <category>IIS</category>
      <category>PowerShell</category>
      <category>Server Maintenance</category>
      <category>Server Management</category>
      <category>Umbraco</category>
      <category>Web Development</category>
    </item>
    <item>
      <trackback:ping>http://blogs.thesitedoctor.co.uk/tim/Trackback.aspx?guid=7d30dc6f-8135-41f6-bb00-5be6f0162d70</trackback:ping>
      <pingback:server>http://blogs.thesitedoctor.co.uk/tim/pingback.aspx</pingback:server>
      <pingback:target>http://blogs.thesitedoctor.co.uk/tim/PermaLink,guid,7d30dc6f-8135-41f6-bb00-5be6f0162d70.aspx</pingback:target>
      <dc:creator>Tim</dc:creator>
      <wfw:comment>http://blogs.thesitedoctor.co.uk/tim/CommentView,guid,7d30dc6f-8135-41f6-bb00-5be6f0162d70.aspx</wfw:comment>
      <wfw:commentRss>http://blogs.thesitedoctor.co.uk/tim/SyndicationService.asmx/GetEntryCommentsRss?guid=7d30dc6f-8135-41f6-bb00-5be6f0162d70</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Exactly a year ago today I posted a little <a href="http://blogs.thesitedoctor.co.uk/tim/2007/07/25/Identify+IIS+Sites+And+Log+File+Locations+For+WWW+And+FTP.aspx">application
that output the sites in IIS to a text file</a> and as a few days ago Lars asked for
the source, I thought it would be a nice thing to release it exactly a year later.
</p>
        <p>
I didn't plan it that way, it just happened! Cool :)
</p>
        <div class="code">
          <h2>Identify IIS Sites and Log File locations for WWW and FTP source
</h2>
          <img src="http//blogs.sitedoc.co.uk/img/sc/clear.gif" align="top" />
          <span style="color: #0000ff">using</span> System; 
<br /><img src="http//blogs.sitedoc.co.uk/img/sc/clear.gif" align="top" /><span style="color: #0000ff">using</span> System<span style="color: #ff0000">.</span>DirectoryServices; 
<br /><img src="http//blogs.sitedoc.co.uk/img/sc/clear.gif" align="top" /><span style="color: #0000ff">using</span> System<span style="color: #ff0000">.</span>IO; 
<br /><img src="http//blogs.sitedoc.co.uk/img/sc/clear.gif" align="top" /><span style="color: #0000ff">using</span> System<span style="color: #ff0000">.</span>Collections; 
<br /><img src="http//blogs.sitedoc.co.uk/img/sc/clear.gif" align="top" /><br /><img src="http//blogs.sitedoc.co.uk/img/sc/clear.gif" align="top" /><span style="color: #0000ff">namespace</span> IISSites 
<br /><div id="closed633525973907034726_7" style="display: none"><img onclick="showHideCodeDiv('633525973907034726_7', false)" src="http//blogs.sitedoc.co.uk/img/sc/PlusNoLines.gif" align="top" /><b><span style="color: #00008b">{...}</span></b></div><div id="open633525973907034726_7" style="display: block"><img onclick="showHideCodeDiv('633525973907034726_7', true)" src="http//blogs.sitedoc.co.uk/img/sc/minusNoTopLine.gif" align="top" />{ 
<br /><img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" />    <span style="color: #0000ff">class</span> Program 
<br /><div id="closed633525973907034726_9" style="display: none"><img onclick="showHideCodeDiv('633525973907034726_9', false)" src="http//blogs.sitedoc.co.uk/img/sc/plus.gif" align="top" />    <b><span style="color: #00008b">{...}</span></b></div><div id="open633525973907034726_9" style="display: block"><img onclick="showHideCodeDiv('633525973907034726_9', true)" src="http//blogs.sitedoc.co.uk/img/sc/minus.gif" align="top" />   
{ 
<br /><img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" />        <span style="color: #0000ff">static</span> <b><span style="color: #0000ff">string</span></b> fileToWrite <span style="color: #ff0000">=</span> <b><span style="color: #48d1cc">String</span></b><span style="color: #ff0000">.</span>Empty; 
<br /><img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /><br /><img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" />       
[STAThread] 
<br /><img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" />        <span style="color: #0000ff">static</span> <b><span style="color: #0000ff">void</span></b> Main(<b><span style="color: #0000ff">string</span></b>[]
args) 
<br /><div id="closed633525973907034726_14" style="display: none"><img onclick="showHideCodeDiv('633525973907034726_14', false)" src="http//blogs.sitedoc.co.uk/img/sc/plus.gif" align="top" />        <b><span style="color: #00008b">{...}</span></b></div><div id="open633525973907034726_14" style="display: block"><img onclick="showHideCodeDiv('633525973907034726_14', true)" src="http//blogs.sitedoc.co.uk/img/sc/minus.gif" align="top" />       
{ 
<br /><img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" />           
fileToWrite <span style="color: #ff0000">=</span> <b><span style="color: #48d1cc">String</span></b><span style="color: #ff0000">.</span>Format(<span style="color: #800000">"</span><span style="color: #800000">IISExport{0:dd-MM-yyyy}.txt"</span>,
DateTime<span style="color: #ff0000">.</span>Today); 
<br /><img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" />            <span style="color: #0000ff">if</span> (args <span style="color: #ff0000">!</span><span style="color: #ff0000">=</span> <span style="color: #0000ff">null</span> &amp;&amp;
args<span style="color: #ff0000">.</span>Length <span style="color: #ff0000">&gt;</span> <b><span style="color: #008080">0</span></b>) 
<br /><div id="closed633525973907034726_17" style="display: none"><img onclick="showHideCodeDiv('633525973907034726_17', false)" src="http//blogs.sitedoc.co.uk/img/sc/plus.gif" align="top" />            <b><span style="color: #00008b">{...}</span></b></div><div id="open633525973907034726_17" style="display: block"><img onclick="showHideCodeDiv('633525973907034726_17', true)" src="http//blogs.sitedoc.co.uk/img/sc/minus.gif" align="top" />           
{ 
<br /><img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" />               
fileToWrite <span style="color: #ff0000">=</span> args[<b><span style="color: #008080">0</span></b>]; 
<br /><img src="http//blogs.sitedoc.co.uk/img/sc/L.gif" align="top" />           
}
</div><img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /><br /><img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" />           
SortedList www <span style="color: #ff0000">=</span> <span style="color: #0000ff">new</span> SortedList(); 
<br /><img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" />           
SortedList ftp <span style="color: #ff0000">=</span> <span style="color: #0000ff">new</span> SortedList(); 
<br /><img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" />            <span style="color: #0000ff">try</span><br /><div id="closed633525973907034726_24" style="display: none"><img onclick="showHideCodeDiv('633525973907034726_24', false)" src="http//blogs.sitedoc.co.uk/img/sc/plus.gif" align="top" />            <b><span style="color: #00008b">{...}</span></b></div><div id="open633525973907034726_24" style="display: block"><img onclick="showHideCodeDiv('633525973907034726_24', true)" src="http//blogs.sitedoc.co.uk/img/sc/minus.gif" align="top" />           
{ 
<br /><img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" />                <span style="color: #0000ff">const</span> <b><span style="color: #0000ff">string</span></b> FtpServerSchema <span style="color: #ff0000">=</span> <span style="color: #800000">"IIsFtpServer"</span>; <span style="color: #3cb371">//
Case Sensitive</span><br /><img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" />                <span style="color: #0000ff">const</span> <b><span style="color: #0000ff">string</span></b> WebServerSchema <span style="color: #ff0000">=</span> <span style="color: #800000">"IIsWebServer"</span>; <span style="color: #3cb371">//
Case Sensitive</span><br /><img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" />                <b><span style="color: #0000ff">string</span></b> ServerName <span style="color: #ff0000">=</span> <span style="color: #800000">"LocalHost"</span>; 
<br /><img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" />               
DirectoryEntry W3SVC <span style="color: #ff0000">=</span> <span style="color: #0000ff">new</span> DirectoryEntry(<span style="color: #800000">"IIS://"</span> <span style="color: #ff0000">+</span> ServerName <span style="color: #ff0000">+</span> <span style="color: #800000">"/w3svc"</span>, <span style="color: #800000">"Domain/UserCode"</span>, <span style="color: #800000">"Password"</span>); 
<br /><img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /><br /><img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" />                <span style="color: #0000ff">foreach</span> (DirectoryEntry
Site <span style="color: #0000ff">in</span> W3SVC<span style="color: #ff0000">.</span>Children) 
<br /><div id="closed633525973907034726_31" style="display: none"><img onclick="showHideCodeDiv('633525973907034726_31', false)" src="http//blogs.sitedoc.co.uk/img/sc/plus.gif" align="top" />                <b><span style="color: #00008b">{...}</span></b></div><div id="open633525973907034726_31" style="display: block"><img onclick="showHideCodeDiv('633525973907034726_31', true)" src="http//blogs.sitedoc.co.uk/img/sc/minus.gif" align="top" />               
{ 
<br /><img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" />                    <span style="color: #0000ff">if</span> (Site<span style="color: #ff0000">.</span>SchemaClassName <span style="color: #ff0000">=</span><span style="color: #ff0000">=</span> WebServerSchema) 
<br /><div id="closed633525973907034726_33" style="display: none"><img onclick="showHideCodeDiv('633525973907034726_33', false)" src="http//blogs.sitedoc.co.uk/img/sc/plus.gif" align="top" />                    <b><span style="color: #00008b">{...}</span></b></div><div id="open633525973907034726_33" style="display: block"><img onclick="showHideCodeDiv('633525973907034726_33', true)" src="http//blogs.sitedoc.co.uk/img/sc/minus.gif" align="top" />                   
{ 
<br /><img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" />                        <b><span style="color: #0000ff">string</span></b> LogFilePath <span style="color: #ff0000">=</span> System<span style="color: #ff0000">.</span>IO<span style="color: #ff0000">.</span>Path<span style="color: #ff0000">.</span>Combine( 
<br /><img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" />                           
Site<span style="color: #ff0000">.</span>Properties[<span style="color: #800000">"LogFileDirectory</span><span style="color: #800000">"</span>]<span style="color: #ff0000">.</span>Value<span style="color: #ff0000">.</span>ToString(), 
<br /><img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" />                            <span style="color: #800000">"W3SVC"</span> <span style="color: #ff0000">+</span> Site<span style="color: #ff0000">.</span>Name); 
<br /><img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" />                       
www<span style="color: #ff0000">.</span>Add(Site<span style="color: #ff0000">.</span>Properties[<span style="color: #800000">"ServerComment"</span>]<span style="color: #ff0000">.</span>Value<span style="color: #ff0000">.</span>ToString(),
LogFilePath); 
<br /><img src="http//blogs.sitedoc.co.uk/img/sc/L.gif" align="top" />                   
}
</div><img src="http//blogs.sitedoc.co.uk/img/sc/L.gif" align="top" />               
}
</div><img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /><br /><img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" />               
DirectoryEntry MSFTPSVC <span style="color: #ff0000">=</span> <span style="color: #0000ff">new</span> DirectoryEntry(<span style="color: #800000">"IIS://"</span> <span style="color: #ff0000">+</span> ServerName <span style="color: #ff0000">+</span> <span style="color: #800000">"/msftpsvc"</span>); 
<br /><img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" />                <span style="color: #0000ff">foreach</span> (DirectoryEntry
Site <span style="color: #0000ff">in</span> MSFTPSVC<span style="color: #ff0000">.</span>Children) 
<br /><div id="closed633525973907034726_43" style="display: none"><img onclick="showHideCodeDiv('633525973907034726_43', false)" src="http//blogs.sitedoc.co.uk/img/sc/plus.gif" align="top" />                <b><span style="color: #00008b">{...}</span></b></div><div id="open633525973907034726_43" style="display: block"><img onclick="showHideCodeDiv('633525973907034726_43', true)" src="http//blogs.sitedoc.co.uk/img/sc/minus.gif" align="top" />               
{ 
<br /><img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" />                    <span style="color: #0000ff">if</span> (Site<span style="color: #ff0000">.</span>SchemaClassName <span style="color: #ff0000">=</span><span style="color: #ff0000">=</span> FtpServerSchema) 
<br /><div id="closed633525973907034726_45" style="display: none"><img onclick="showHideCodeDiv('633525973907034726_45', false)" src="http//blogs.sitedoc.co.uk/img/sc/plus.gif" align="top" />                    <b><span style="color: #00008b">{...}</span></b></div><div id="open633525973907034726_45" style="display: block"><img onclick="showHideCodeDiv('633525973907034726_45', true)" src="http//blogs.sitedoc.co.uk/img/sc/minus.gif" align="top" />                   
{ 
<br /><img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" />                        <b><span style="color: #0000ff">string</span></b> LogFilePath <span style="color: #ff0000">=</span> System<span style="color: #ff0000">.</span>IO<span style="color: #ff0000">.</span>Path<span style="color: #ff0000">.</span>Combine( 
<br /><img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" />                           
Site<span style="color: #ff0000">.</span>Properties[<span style="color: #800000">"LogFileDirectory</span><span style="color: #800000">"</span>]<span style="color: #ff0000">.</span>Value<span style="color: #ff0000">.</span>ToString(), 
<br /><img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" />                            <span style="color: #800000">"MSFTPSVC"</span> <span style="color: #ff0000">+</span> Site<span style="color: #ff0000">.</span>Name); 
<br /><img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" />                       
ftp<span style="color: #ff0000">.</span>Add(Site<span style="color: #ff0000">.</span>Properties[<span style="color: #800000">"ServerComment"</span>]<span style="color: #ff0000">.</span>Value<span style="color: #ff0000">.</span>ToString(),
LogFilePath); 
<br /><img src="http//blogs.sitedoc.co.uk/img/sc/L.gif" align="top" />                   
}
</div><img src="http//blogs.sitedoc.co.uk/img/sc/L.gif" align="top" />               
}
</div><img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" />                <b><span style="color: #0000ff">int</span></b> MaxWidth <span style="color: #ff0000">=</span> <b><span style="color: #008080">0</span></b>; 
<br /><img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" />                <span style="color: #0000ff">foreach</span> (<b><span style="color: #0000ff">string</span></b> Site
in www<span style="color: #ff0000">.</span>Keys) 
<br /><div id="closed633525973907034726_54" style="display: none"><img onclick="showHideCodeDiv('633525973907034726_54', false)" src="http//blogs.sitedoc.co.uk/img/sc/plus.gif" align="top" />                <b><span style="color: #00008b">{...}</span></b></div><div id="open633525973907034726_54" style="display: block"><img onclick="showHideCodeDiv('633525973907034726_54', true)" src="http//blogs.sitedoc.co.uk/img/sc/minus.gif" align="top" />               
{ 
<br /><img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" />                    <span style="color: #0000ff">if</span> (Site<span style="color: #ff0000">.</span>Length <span style="color: #ff0000">&gt;</span> MaxWidth) 
<br /><img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" />                       
MaxWidth <span style="color: #ff0000">=</span> Site<span style="color: #ff0000">.</span>Length; 
<br /><img src="http//blogs.sitedoc.co.uk/img/sc/L.gif" align="top" />               
}
</div><img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" />                <span style="color: #0000ff">foreach</span> (<b><span style="color: #0000ff">string</span></b> Site
in ftp<span style="color: #ff0000">.</span>Keys) 
<br /><div id="closed633525973907034726_59" style="display: none"><img onclick="showHideCodeDiv('633525973907034726_59', false)" src="http//blogs.sitedoc.co.uk/img/sc/plus.gif" align="top" />                <b><span style="color: #00008b">{...}</span></b></div><div id="open633525973907034726_59" style="display: block"><img onclick="showHideCodeDiv('633525973907034726_59', true)" src="http//blogs.sitedoc.co.uk/img/sc/minus.gif" align="top" />               
{ 
<br /><img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" />                    <span style="color: #0000ff">if</span> (Site<span style="color: #ff0000">.</span>Length <span style="color: #ff0000">&gt;</span> MaxWidth) 
<br /><img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" />                       
MaxWidth <span style="color: #ff0000">=</span> Site<span style="color: #ff0000">.</span>Length; 
<br /><img src="http//blogs.sitedoc.co.uk/img/sc/L.gif" align="top" />               
}
</div><img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" />               
OutputIt(<span style="color: #800000">"Site</span> <span style="color: #800000">Description"</span><span style="color: #ff0000">.</span>PadRight(MaxWidth) <span style="color: #ff0000">+</span> <span style="color: #800000">" 
Log File Directory"</span>); 
<br /><img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" />               
OutputIt(<span style="color: #800000">""</span><span style="color: #ff0000">.</span>PadRight(<b><span style="color: #008080">79</span></b>, <span style="color: #800000">'</span><span style="color: #800000">='</span>)); 
<br /><img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" />               
OutputIt(<b><span style="color: #48d1cc">String</span></b><span style="color: #ff0000">.Empty);</span><br /><img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" />               
OutputIt(<span style="color: #800000">"WWW</span> <span style="color: #800000">Sites"</span>); 
<br /><img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" />               
OutputIt(<span style="color: #800000">"=========</span><span style="color: #800000">"</span>); 
<br /><img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" />                <span style="color: #0000ff">foreach</span> (<b><span style="color: #0000ff">string</span></b> Site
in www<span style="color: #ff0000">.</span>Keys) 
<br /><div id="closed633525973907034726_69" style="display: none"><img onclick="showHideCodeDiv('633525973907034726_69', false)" src="http//blogs.sitedoc.co.uk/img/sc/plus.gif" align="top" />                <b><span style="color: #00008b">{...}</span></b></div><div id="open633525973907034726_69" style="display: block"><img onclick="showHideCodeDiv('633525973907034726_69', true)" src="http//blogs.sitedoc.co.uk/img/sc/minus.gif" align="top" />               
{ 
<br /><img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" />                    <b><span style="color: #0000ff">string</span></b> output <span style="color: #ff0000">=</span> Site<span style="color: #ff0000">.</span>PadRight(MaxWidth) <span style="color: #ff0000">+</span> <span style="color: #800000">" 
"</span> <span style="color: #ff0000">+</span> www[Site]; 
<br /><img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" />                   
Console<span style="color: #ff0000">.</span>WriteLine(output); 
<br /><img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" />                   
OutputIt(output); 
<br /><img src="http//blogs.sitedoc.co.uk/img/sc/L.gif" align="top" />               
}
</div><img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" />                <span style="color: #0000ff">if</span> (ftp<span style="color: #ff0000">.</span>Keys<span style="color: #ff0000">.</span>Count <span style="color: #ff0000">&gt;</span> <b><span style="color: #008080">0</span></b>) 
<br /><div id="closed633525973907034726_75" style="display: none"><img onclick="showHideCodeDiv('633525973907034726_75', false)" src="http//blogs.sitedoc.co.uk/img/sc/plus.gif" align="top" />                <b><span style="color: #00008b">{...}</span></b></div><div id="open633525973907034726_75" style="display: block"><img onclick="showHideCodeDiv('633525973907034726_75', true)" src="http//blogs.sitedoc.co.uk/img/sc/minus.gif" align="top" />               
{ 
<br /><img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" />                   
OutputIt(<b><span style="color: #48d1cc">String</span></b><span style="color: #ff0000">.Empty);</span><br /><img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" />                   
OutputIt(<span style="color: #800000">"FTP</span> <span style="color: #800000">Sites"</span>); 
<br /><img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" />                   
OutputIt(<span style="color: #800000">"=========</span><span style="color: #800000">"</span>); 
<br /><img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" />                    <span style="color: #0000ff">foreach</span> (<b><span style="color: #0000ff">string</span></b> Site
in ftp<span style="color: #ff0000">.</span>Keys) 
<br /><div id="closed633525973907034726_80" style="display: none"><img onclick="showHideCodeDiv('633525973907034726_80', false)" src="http//blogs.sitedoc.co.uk/img/sc/plus.gif" align="top" />                    <b><span style="color: #00008b">{...}</span></b></div><div id="open633525973907034726_80" style="display: block"><img onclick="showHideCodeDiv('633525973907034726_80', true)" src="http//blogs.sitedoc.co.uk/img/sc/minus.gif" align="top" />                   
{ 
<br /><img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" />                        <b><span style="color: #0000ff">string</span></b> output <span style="color: #ff0000">=</span> Site<span style="color: #ff0000">.</span>PadRight(MaxWidth) <span style="color: #ff0000">+</span> <span style="color: #800000">" 
"</span> <span style="color: #ff0000">+</span> ftp[Site]; 
<br /><img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" />                       
OutputIt(output); 
<br /><img src="http//blogs.sitedoc.co.uk/img/sc/L.gif" align="top" />                   
}
</div><img src="http//blogs.sitedoc.co.uk/img/sc/L.gif" align="top" />               
}
</div><img src="http//blogs.sitedoc.co.uk/img/sc/L.gif" align="top" />           
}
</div><img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" />            <span style="color: #3cb371">//
Catch any errors</span><br /><img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" />            <span style="color: #0000ff">catch</span> (Exception
e) 
<br /><div id="closed633525973907034726_88" style="display: none"><img onclick="showHideCodeDiv('633525973907034726_88', false)" src="http//blogs.sitedoc.co.uk/img/sc/plus.gif" align="top" />            <b><span style="color: #00008b">{...}</span></b></div><div id="open633525973907034726_88" style="display: block"><img onclick="showHideCodeDiv('633525973907034726_88', true)" src="http//blogs.sitedoc.co.uk/img/sc/minus.gif" align="top" />           
{ 
<br /><img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" />               
Console<span style="color: #ff0000">.</span>WriteLine(<span style="color: #800000">"Error:</span> <span style="color: #800000">"</span> <span style="color: #ff0000">+</span> e<span style="color: #ff0000">.</span>ToString()); 
<br /><img src="http//blogs.sitedoc.co.uk/img/sc/L.gif" align="top" />           
}
</div><img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" />            <span style="color: #0000ff">finally</span><br /><div id="closed633525973907034726_92" style="display: none"><img onclick="showHideCodeDiv('633525973907034726_92', false)" src="http//blogs.sitedoc.co.uk/img/sc/plus.gif" align="top" />            <b><span style="color: #00008b">{...}</span></b></div><div id="open633525973907034726_92" style="display: block"><img onclick="showHideCodeDiv('633525973907034726_92', true)" src="http//blogs.sitedoc.co.uk/img/sc/minus.gif" align="top" />           
{ 
<br /><img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" />               
Console<span style="color: #ff0000">.</span>WriteLine(); 
<br /><img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" />               
Console<span style="color: #ff0000">.</span>WriteLine(<span style="color: #800000">"Press</span> <span style="color: #800000">enter
to close/exit..."</span>); 
<br /><img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" />                <span style="color: #3cb371">//Console.Read();</span><br /><img src="http//blogs.sitedoc.co.uk/img/sc/L.gif" align="top" />           
}
</div><img src="http//blogs.sitedoc.co.uk/img/sc/L.gif" align="top" />       
}
</div><img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /><br /><img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" />        <span style="color: #0000ff">static</span> <b><span style="color: #0000ff">void</span></b> OutputIt(<b><span style="color: #0000ff">string</span></b> lineToAdd) 
<br /><div id="closed633525973907034726_100" style="display: none"><img onclick="showHideCodeDiv('633525973907034726_100', false)" src="http//blogs.sitedoc.co.uk/img/sc/plus.gif" align="top" />        <b><span style="color: #00008b">{...}</span></b></div><div id="open633525973907034726_100" style="display: block"><img onclick="showHideCodeDiv('633525973907034726_100', true)" src="http//blogs.sitedoc.co.uk/img/sc/minus.gif" align="top" />       
{ 
<br /><img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" />           
Console<span style="color: #ff0000">.</span>WriteLine(lineToAdd); 
<br /><img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /><br /><img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" />            <span style="color: #0000ff">if</span> (<span style="color: #ff0000">!</span><b><span style="color: #48d1cc">String</span></b><span style="color: #ff0000">.</span>IsNullOrEmpty(fileToWrite)) 
<br /><div id="closed633525973907034726_104" style="display: none"><img onclick="showHideCodeDiv('633525973907034726_104', false)" src="http//blogs.sitedoc.co.uk/img/sc/plus.gif" align="top" />            <b><span style="color: #00008b">{...}</span></b></div><div id="open633525973907034726_104" style="display: block"><img onclick="showHideCodeDiv('633525973907034726_104', true)" src="http//blogs.sitedoc.co.uk/img/sc/minus.gif" align="top" />           
{ 
<br /><img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" />               
StreamWriter SW; 
<br /><img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" />               
SW <span style="color: #ff0000">=</span> File<span style="color: #ff0000">.</span>AppendText(fileToWrite); 
<br /><img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" />               
SW<span style="color: #ff0000">.</span>WriteLine(lineToAdd); 
<br /><img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" />               
SW<span style="color: #ff0000">.</span>Close(); 
<br /><img src="http//blogs.sitedoc.co.uk/img/sc/L.gif" align="top" />           
}
</div><img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" />            <span style="color: #0000ff">else</span><br /><div id="closed633525973907034726_111" style="display: none"><img onclick="showHideCodeDiv('633525973907034726_111', false)" src="http//blogs.sitedoc.co.uk/img/sc/plus.gif" align="top" />            <b><span style="color: #00008b">{...}</span></b></div><div id="open633525973907034726_111" style="display: block"><img onclick="showHideCodeDiv('633525973907034726_111', true)" src="http//blogs.sitedoc.co.uk/img/sc/minus.gif" align="top" />           
{ 
<br /><img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" />               
Console<span style="color: #ff0000">.</span>WriteLine(<span style="color: #800000">"locationToOutput</span> <span style="color: #800000">is
Null or String.Empty please supply a value and try again."</span>); 
<br /><img src="http//blogs.sitedoc.co.uk/img/sc/L.gif" align="top" />           
}
</div><img src="http//blogs.sitedoc.co.uk/img/sc/L.gif" align="top" />       
}
</div><img src="http//blogs.sitedoc.co.uk/img/sc/L.gif" align="top" />   
}
</div><img src="http//blogs.sitedoc.co.uk/img/sc/L.gif" align="top" />}
</div></div>
        <img width="0" height="0" src="http://blogs.thesitedoctor.co.uk/tim/aggbug.ashx?id=7d30dc6f-8135-41f6-bb00-5be6f0162d70" />
      </body>
      <title>Identify IIS Sites and Log File locations for WWW and FTP &amp;ndash;the source</title>
      <guid isPermaLink="false">http://blogs.thesitedoctor.co.uk/tim/PermaLink,guid,7d30dc6f-8135-41f6-bb00-5be6f0162d70.aspx</guid>
      <link>http://blogs.thesitedoctor.co.uk/tim/2008/07/25/Identify+IIS+Sites+And+Log+File+Locations+For+WWW+And+FTP+Ndashthe+Source.aspx</link>
      <pubDate>Fri, 25 Jul 2008 14:52:37 GMT</pubDate>
      <description>&lt;p&gt;
Exactly a year ago today I posted a little &lt;a href="http://blogs.thesitedoctor.co.uk/tim/2007/07/25/Identify+IIS+Sites+And+Log+File+Locations+For+WWW+And+FTP.aspx"&gt;application
that output the sites in IIS to a text file&lt;/a&gt; and as a few days ago Lars asked for
the source, I thought it would be a nice thing to release it exactly a year later.
&lt;/p&gt;
&lt;p&gt;
I didn't plan it that way, it just happened! Cool :)
&lt;/p&gt;
&lt;div class="code"&gt;
&lt;h2&gt;Identify IIS Sites and Log File locations for WWW and FTP source
&lt;/h2&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/clear.gif" align="top" /&gt;&lt;span style="color: #0000ff"&gt;using&lt;/span&gt; System; 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/clear.gif" align="top" /&gt;&lt;span style="color: #0000ff"&gt;using&lt;/span&gt; System&lt;span style="color: #ff0000"&gt;.&lt;/span&gt;DirectoryServices; 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/clear.gif" align="top" /&gt;&lt;span style="color: #0000ff"&gt;using&lt;/span&gt; System&lt;span style="color: #ff0000"&gt;.&lt;/span&gt;IO; 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/clear.gif" align="top" /&gt;&lt;span style="color: #0000ff"&gt;using&lt;/span&gt; System&lt;span style="color: #ff0000"&gt;.&lt;/span&gt;Collections; 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/clear.gif" align="top" /&gt; 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/clear.gif" align="top" /&gt;&lt;span style="color: #0000ff"&gt;namespace&lt;/span&gt; IISSites 
&lt;br /&gt;
&lt;div id="closed633525973907034726_7" style="display: none"&gt;&lt;img onclick="showHideCodeDiv(&amp;#39;633525973907034726_7&amp;#39;, false)" src="http//blogs.sitedoc.co.uk/img/sc/PlusNoLines.gif" align="top" /&gt;&lt;b&gt;&lt;span style="color: #00008b"&gt;{...}&lt;/span&gt;&lt;/b&gt;
&lt;/div&gt;
&lt;div id="open633525973907034726_7" style="display: block"&gt;&lt;img onclick="showHideCodeDiv(&amp;#39;633525973907034726_7&amp;#39;, true)" src="http//blogs.sitedoc.co.uk/img/sc/minusNoTopLine.gif" align="top" /&gt;{ 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; Program 
&lt;br /&gt;
&lt;div id="closed633525973907034726_9" style="display: none"&gt;&lt;img onclick="showHideCodeDiv(&amp;#39;633525973907034726_9&amp;#39;, false)" src="http//blogs.sitedoc.co.uk/img/sc/plus.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;b&gt;&lt;span style="color: #00008b"&gt;{...}&lt;/span&gt;&lt;/b&gt;
&lt;/div&gt;
&lt;div id="open633525973907034726_9" style="display: block"&gt;&lt;img onclick="showHideCodeDiv(&amp;#39;633525973907034726_9&amp;#39;, true)" src="http//blogs.sitedoc.co.uk/img/sc/minus.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;
{ 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt;&amp;#160;&lt;b&gt;&lt;span style="color: #0000ff"&gt;string&lt;/span&gt;&lt;/b&gt; fileToWrite &lt;span style="color: #ff0000"&gt;=&lt;/span&gt;&amp;#160;&lt;b&gt;&lt;span style="color: #48d1cc"&gt;String&lt;/span&gt;&lt;/b&gt;&lt;span style="color: #ff0000"&gt;.&lt;/span&gt;Empty; 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /&gt; 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
[STAThread] 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt;&amp;#160;&lt;b&gt;&lt;span style="color: #0000ff"&gt;void&lt;/span&gt;&lt;/b&gt; Main(&lt;b&gt;&lt;span style="color: #0000ff"&gt;string&lt;/span&gt;&lt;/b&gt;[]
args) 
&lt;br /&gt;
&lt;div id="closed633525973907034726_14" style="display: none"&gt;&lt;img onclick="showHideCodeDiv(&amp;#39;633525973907034726_14&amp;#39;, false)" src="http//blogs.sitedoc.co.uk/img/sc/plus.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;b&gt;&lt;span style="color: #00008b"&gt;{...}&lt;/span&gt;&lt;/b&gt;
&lt;/div&gt;
&lt;div id="open633525973907034726_14" style="display: block"&gt;&lt;img onclick="showHideCodeDiv(&amp;#39;633525973907034726_14&amp;#39;, true)" src="http//blogs.sitedoc.co.uk/img/sc/minus.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
{ 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
fileToWrite &lt;span style="color: #ff0000"&gt;=&lt;/span&gt;&amp;#160;&lt;b&gt;&lt;span style="color: #48d1cc"&gt;String&lt;/span&gt;&lt;/b&gt;&lt;span style="color: #ff0000"&gt;.&lt;/span&gt;Format(&lt;span style="color: #800000"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #800000"&gt;IISExport{0:dd-MM-yyyy}.txt&amp;quot;&lt;/span&gt;,
DateTime&lt;span style="color: #ff0000"&gt;.&lt;/span&gt;Today); 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (args &lt;span style="color: #ff0000"&gt;!&lt;/span&gt;&lt;span style="color: #ff0000"&gt;=&lt;/span&gt;&amp;#160;&lt;span style="color: #0000ff"&gt;null&lt;/span&gt; &amp;amp;&amp;amp;
args&lt;span style="color: #ff0000"&gt;.&lt;/span&gt;Length &lt;span style="color: #ff0000"&gt;&amp;gt;&lt;/span&gt;&amp;#160;&lt;b&gt;&lt;span style="color: #008080"&gt;0&lt;/span&gt;&lt;/b&gt;) 
&lt;br /&gt;
&lt;div id="closed633525973907034726_17" style="display: none"&gt;&lt;img onclick="showHideCodeDiv(&amp;#39;633525973907034726_17&amp;#39;, false)" src="http//blogs.sitedoc.co.uk/img/sc/plus.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;b&gt;&lt;span style="color: #00008b"&gt;{...}&lt;/span&gt;&lt;/b&gt;
&lt;/div&gt;
&lt;div id="open633525973907034726_17" style="display: block"&gt;&lt;img onclick="showHideCodeDiv(&amp;#39;633525973907034726_17&amp;#39;, true)" src="http//blogs.sitedoc.co.uk/img/sc/minus.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
{ 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
fileToWrite &lt;span style="color: #ff0000"&gt;=&lt;/span&gt; args[&lt;b&gt;&lt;span style="color: #008080"&gt;0&lt;/span&gt;&lt;/b&gt;]; 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/L.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
}
&lt;/div&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /&gt; 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
SortedList www &lt;span style="color: #ff0000"&gt;=&lt;/span&gt;&amp;#160;&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; SortedList(); 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
SortedList ftp &lt;span style="color: #ff0000"&gt;=&lt;/span&gt;&amp;#160;&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; SortedList(); 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #0000ff"&gt;try&lt;/span&gt; 
&lt;br /&gt;
&lt;div id="closed633525973907034726_24" style="display: none"&gt;&lt;img onclick="showHideCodeDiv(&amp;#39;633525973907034726_24&amp;#39;, false)" src="http//blogs.sitedoc.co.uk/img/sc/plus.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;b&gt;&lt;span style="color: #00008b"&gt;{...}&lt;/span&gt;&lt;/b&gt;
&lt;/div&gt;
&lt;div id="open633525973907034726_24" style="display: block"&gt;&lt;img onclick="showHideCodeDiv(&amp;#39;633525973907034726_24&amp;#39;, true)" src="http//blogs.sitedoc.co.uk/img/sc/minus.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
{ 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #0000ff"&gt;const&lt;/span&gt;&amp;#160;&lt;b&gt;&lt;span style="color: #0000ff"&gt;string&lt;/span&gt;&lt;/b&gt; FtpServerSchema &lt;span style="color: #ff0000"&gt;=&lt;/span&gt;&amp;#160;&lt;span style="color: #800000"&gt;&amp;quot;IIsFtpServer&amp;quot;&lt;/span&gt;; &lt;span style="color: #3cb371"&gt;//
Case Sensitive&lt;/span&gt; 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #0000ff"&gt;const&lt;/span&gt;&amp;#160;&lt;b&gt;&lt;span style="color: #0000ff"&gt;string&lt;/span&gt;&lt;/b&gt; WebServerSchema &lt;span style="color: #ff0000"&gt;=&lt;/span&gt;&amp;#160;&lt;span style="color: #800000"&gt;&amp;quot;IIsWebServer&amp;quot;&lt;/span&gt;; &lt;span style="color: #3cb371"&gt;//
Case Sensitive&lt;/span&gt; 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;b&gt;&lt;span style="color: #0000ff"&gt;string&lt;/span&gt;&lt;/b&gt; ServerName &lt;span style="color: #ff0000"&gt;=&lt;/span&gt;&amp;#160;&lt;span style="color: #800000"&gt;&amp;quot;LocalHost&amp;quot;&lt;/span&gt;; 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
DirectoryEntry W3SVC &lt;span style="color: #ff0000"&gt;=&lt;/span&gt;&amp;#160;&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; DirectoryEntry(&lt;span style="color: #800000"&gt;&amp;quot;IIS://&amp;quot;&lt;/span&gt;&amp;#160;&lt;span style="color: #ff0000"&gt;+&lt;/span&gt; ServerName &lt;span style="color: #ff0000"&gt;+&lt;/span&gt;&amp;#160;&lt;span style="color: #800000"&gt;&amp;quot;/w3svc&amp;quot;&lt;/span&gt;, &lt;span style="color: #800000"&gt;&amp;quot;Domain/UserCode&amp;quot;&lt;/span&gt;, &lt;span style="color: #800000"&gt;&amp;quot;Password&amp;quot;&lt;/span&gt;); 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /&gt; 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #0000ff"&gt;foreach&lt;/span&gt; (DirectoryEntry
Site &lt;span style="color: #0000ff"&gt;in&lt;/span&gt; W3SVC&lt;span style="color: #ff0000"&gt;.&lt;/span&gt;Children) 
&lt;br /&gt;
&lt;div id="closed633525973907034726_31" style="display: none"&gt;&lt;img onclick="showHideCodeDiv(&amp;#39;633525973907034726_31&amp;#39;, false)" src="http//blogs.sitedoc.co.uk/img/sc/plus.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;b&gt;&lt;span style="color: #00008b"&gt;{...}&lt;/span&gt;&lt;/b&gt;
&lt;/div&gt;
&lt;div id="open633525973907034726_31" style="display: block"&gt;&lt;img onclick="showHideCodeDiv(&amp;#39;633525973907034726_31&amp;#39;, true)" src="http//blogs.sitedoc.co.uk/img/sc/minus.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
{ 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (Site&lt;span style="color: #ff0000"&gt;.&lt;/span&gt;SchemaClassName &lt;span style="color: #ff0000"&gt;=&lt;/span&gt;&lt;span style="color: #ff0000"&gt;=&lt;/span&gt; WebServerSchema) 
&lt;br /&gt;
&lt;div id="closed633525973907034726_33" style="display: none"&gt;&lt;img onclick="showHideCodeDiv(&amp;#39;633525973907034726_33&amp;#39;, false)" src="http//blogs.sitedoc.co.uk/img/sc/plus.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;b&gt;&lt;span style="color: #00008b"&gt;{...}&lt;/span&gt;&lt;/b&gt;
&lt;/div&gt;
&lt;div id="open633525973907034726_33" style="display: block"&gt;&lt;img onclick="showHideCodeDiv(&amp;#39;633525973907034726_33&amp;#39;, true)" src="http//blogs.sitedoc.co.uk/img/sc/minus.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
{ 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;b&gt;&lt;span style="color: #0000ff"&gt;string&lt;/span&gt;&lt;/b&gt; LogFilePath &lt;span style="color: #ff0000"&gt;=&lt;/span&gt; System&lt;span style="color: #ff0000"&gt;.&lt;/span&gt;IO&lt;span style="color: #ff0000"&gt;.&lt;/span&gt;Path&lt;span style="color: #ff0000"&gt;.&lt;/span&gt;Combine( 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
Site&lt;span style="color: #ff0000"&gt;.&lt;/span&gt;Properties[&lt;span style="color: #800000"&gt;&amp;quot;LogFileDirectory&lt;/span&gt;&lt;span style="color: #800000"&gt;&amp;quot;&lt;/span&gt;]&lt;span style="color: #ff0000"&gt;.&lt;/span&gt;Value&lt;span style="color: #ff0000"&gt;.&lt;/span&gt;ToString(), 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #800000"&gt;&amp;quot;W3SVC&amp;quot;&lt;/span&gt;&amp;#160;&lt;span style="color: #ff0000"&gt;+&lt;/span&gt; Site&lt;span style="color: #ff0000"&gt;.&lt;/span&gt;Name); 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
www&lt;span style="color: #ff0000"&gt;.&lt;/span&gt;Add(Site&lt;span style="color: #ff0000"&gt;.&lt;/span&gt;Properties[&lt;span style="color: #800000"&gt;&amp;quot;ServerComment&amp;quot;&lt;/span&gt;]&lt;span style="color: #ff0000"&gt;.&lt;/span&gt;Value&lt;span style="color: #ff0000"&gt;.&lt;/span&gt;ToString(),
LogFilePath); 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/L.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
}
&lt;/div&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/L.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
}
&lt;/div&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /&gt; 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
DirectoryEntry MSFTPSVC &lt;span style="color: #ff0000"&gt;=&lt;/span&gt;&amp;#160;&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; DirectoryEntry(&lt;span style="color: #800000"&gt;&amp;quot;IIS://&amp;quot;&lt;/span&gt;&amp;#160;&lt;span style="color: #ff0000"&gt;+&lt;/span&gt; ServerName &lt;span style="color: #ff0000"&gt;+&lt;/span&gt;&amp;#160;&lt;span style="color: #800000"&gt;&amp;quot;/msftpsvc&amp;quot;&lt;/span&gt;); 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #0000ff"&gt;foreach&lt;/span&gt; (DirectoryEntry
Site &lt;span style="color: #0000ff"&gt;in&lt;/span&gt; MSFTPSVC&lt;span style="color: #ff0000"&gt;.&lt;/span&gt;Children) 
&lt;br /&gt;
&lt;div id="closed633525973907034726_43" style="display: none"&gt;&lt;img onclick="showHideCodeDiv(&amp;#39;633525973907034726_43&amp;#39;, false)" src="http//blogs.sitedoc.co.uk/img/sc/plus.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;b&gt;&lt;span style="color: #00008b"&gt;{...}&lt;/span&gt;&lt;/b&gt;
&lt;/div&gt;
&lt;div id="open633525973907034726_43" style="display: block"&gt;&lt;img onclick="showHideCodeDiv(&amp;#39;633525973907034726_43&amp;#39;, true)" src="http//blogs.sitedoc.co.uk/img/sc/minus.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
{ 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (Site&lt;span style="color: #ff0000"&gt;.&lt;/span&gt;SchemaClassName &lt;span style="color: #ff0000"&gt;=&lt;/span&gt;&lt;span style="color: #ff0000"&gt;=&lt;/span&gt; FtpServerSchema) 
&lt;br /&gt;
&lt;div id="closed633525973907034726_45" style="display: none"&gt;&lt;img onclick="showHideCodeDiv(&amp;#39;633525973907034726_45&amp;#39;, false)" src="http//blogs.sitedoc.co.uk/img/sc/plus.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;b&gt;&lt;span style="color: #00008b"&gt;{...}&lt;/span&gt;&lt;/b&gt;
&lt;/div&gt;
&lt;div id="open633525973907034726_45" style="display: block"&gt;&lt;img onclick="showHideCodeDiv(&amp;#39;633525973907034726_45&amp;#39;, true)" src="http//blogs.sitedoc.co.uk/img/sc/minus.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
{ 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;b&gt;&lt;span style="color: #0000ff"&gt;string&lt;/span&gt;&lt;/b&gt; LogFilePath &lt;span style="color: #ff0000"&gt;=&lt;/span&gt; System&lt;span style="color: #ff0000"&gt;.&lt;/span&gt;IO&lt;span style="color: #ff0000"&gt;.&lt;/span&gt;Path&lt;span style="color: #ff0000"&gt;.&lt;/span&gt;Combine( 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
Site&lt;span style="color: #ff0000"&gt;.&lt;/span&gt;Properties[&lt;span style="color: #800000"&gt;&amp;quot;LogFileDirectory&lt;/span&gt;&lt;span style="color: #800000"&gt;&amp;quot;&lt;/span&gt;]&lt;span style="color: #ff0000"&gt;.&lt;/span&gt;Value&lt;span style="color: #ff0000"&gt;.&lt;/span&gt;ToString(), 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #800000"&gt;&amp;quot;MSFTPSVC&amp;quot;&lt;/span&gt;&amp;#160;&lt;span style="color: #ff0000"&gt;+&lt;/span&gt; Site&lt;span style="color: #ff0000"&gt;.&lt;/span&gt;Name); 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
ftp&lt;span style="color: #ff0000"&gt;.&lt;/span&gt;Add(Site&lt;span style="color: #ff0000"&gt;.&lt;/span&gt;Properties[&lt;span style="color: #800000"&gt;&amp;quot;ServerComment&amp;quot;&lt;/span&gt;]&lt;span style="color: #ff0000"&gt;.&lt;/span&gt;Value&lt;span style="color: #ff0000"&gt;.&lt;/span&gt;ToString(),
LogFilePath); 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/L.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
}
&lt;/div&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/L.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
}
&lt;/div&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;b&gt;&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;&lt;/b&gt; MaxWidth &lt;span style="color: #ff0000"&gt;=&lt;/span&gt;&amp;#160;&lt;b&gt;&lt;span style="color: #008080"&gt;0&lt;/span&gt;&lt;/b&gt;; 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #0000ff"&gt;foreach&lt;/span&gt; (&lt;b&gt;&lt;span style="color: #0000ff"&gt;string&lt;/span&gt;&lt;/b&gt; Site
in www&lt;span style="color: #ff0000"&gt;.&lt;/span&gt;Keys) 
&lt;br /&gt;
&lt;div id="closed633525973907034726_54" style="display: none"&gt;&lt;img onclick="showHideCodeDiv(&amp;#39;633525973907034726_54&amp;#39;, false)" src="http//blogs.sitedoc.co.uk/img/sc/plus.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;b&gt;&lt;span style="color: #00008b"&gt;{...}&lt;/span&gt;&lt;/b&gt;
&lt;/div&gt;
&lt;div id="open633525973907034726_54" style="display: block"&gt;&lt;img onclick="showHideCodeDiv(&amp;#39;633525973907034726_54&amp;#39;, true)" src="http//blogs.sitedoc.co.uk/img/sc/minus.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
{ 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (Site&lt;span style="color: #ff0000"&gt;.&lt;/span&gt;Length &lt;span style="color: #ff0000"&gt;&amp;gt;&lt;/span&gt; MaxWidth) 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
MaxWidth &lt;span style="color: #ff0000"&gt;=&lt;/span&gt; Site&lt;span style="color: #ff0000"&gt;.&lt;/span&gt;Length; 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/L.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
}
&lt;/div&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #0000ff"&gt;foreach&lt;/span&gt; (&lt;b&gt;&lt;span style="color: #0000ff"&gt;string&lt;/span&gt;&lt;/b&gt; Site
in ftp&lt;span style="color: #ff0000"&gt;.&lt;/span&gt;Keys) 
&lt;br /&gt;
&lt;div id="closed633525973907034726_59" style="display: none"&gt;&lt;img onclick="showHideCodeDiv(&amp;#39;633525973907034726_59&amp;#39;, false)" src="http//blogs.sitedoc.co.uk/img/sc/plus.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;b&gt;&lt;span style="color: #00008b"&gt;{...}&lt;/span&gt;&lt;/b&gt;
&lt;/div&gt;
&lt;div id="open633525973907034726_59" style="display: block"&gt;&lt;img onclick="showHideCodeDiv(&amp;#39;633525973907034726_59&amp;#39;, true)" src="http//blogs.sitedoc.co.uk/img/sc/minus.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
{ 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (Site&lt;span style="color: #ff0000"&gt;.&lt;/span&gt;Length &lt;span style="color: #ff0000"&gt;&amp;gt;&lt;/span&gt; MaxWidth) 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
MaxWidth &lt;span style="color: #ff0000"&gt;=&lt;/span&gt; Site&lt;span style="color: #ff0000"&gt;.&lt;/span&gt;Length; 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/L.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
}
&lt;/div&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
OutputIt(&lt;span style="color: #800000"&gt;&amp;quot;Site&lt;/span&gt;&amp;#160;&lt;span style="color: #800000"&gt;Description&amp;quot;&lt;/span&gt;&lt;span style="color: #ff0000"&gt;.&lt;/span&gt;PadRight(MaxWidth) &lt;span style="color: #ff0000"&gt;+&lt;/span&gt;&amp;#160;&lt;span style="color: #800000"&gt;&amp;quot;&amp;#160;
Log File Directory&amp;quot;&lt;/span&gt;); 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
OutputIt(&lt;span style="color: #800000"&gt;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span style="color: #ff0000"&gt;.&lt;/span&gt;PadRight(&lt;b&gt;&lt;span style="color: #008080"&gt;79&lt;/span&gt;&lt;/b&gt;, &lt;span style="color: #800000"&gt;'&lt;/span&gt;&lt;span style="color: #800000"&gt;='&lt;/span&gt;)); 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
OutputIt(&lt;b&gt;&lt;span style="color: #48d1cc"&gt;String&lt;/span&gt;&lt;/b&gt;&lt;span style="color: #ff0000"&gt;.Empty);&lt;/span&gt; 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
OutputIt(&lt;span style="color: #800000"&gt;&amp;quot;WWW&lt;/span&gt;&amp;#160;&lt;span style="color: #800000"&gt;Sites&amp;quot;&lt;/span&gt;); 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
OutputIt(&lt;span style="color: #800000"&gt;&amp;quot;=========&lt;/span&gt;&lt;span style="color: #800000"&gt;&amp;quot;&lt;/span&gt;); 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #0000ff"&gt;foreach&lt;/span&gt; (&lt;b&gt;&lt;span style="color: #0000ff"&gt;string&lt;/span&gt;&lt;/b&gt; Site
in www&lt;span style="color: #ff0000"&gt;.&lt;/span&gt;Keys) 
&lt;br /&gt;
&lt;div id="closed633525973907034726_69" style="display: none"&gt;&lt;img onclick="showHideCodeDiv(&amp;#39;633525973907034726_69&amp;#39;, false)" src="http//blogs.sitedoc.co.uk/img/sc/plus.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;b&gt;&lt;span style="color: #00008b"&gt;{...}&lt;/span&gt;&lt;/b&gt;
&lt;/div&gt;
&lt;div id="open633525973907034726_69" style="display: block"&gt;&lt;img onclick="showHideCodeDiv(&amp;#39;633525973907034726_69&amp;#39;, true)" src="http//blogs.sitedoc.co.uk/img/sc/minus.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
{ 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;b&gt;&lt;span style="color: #0000ff"&gt;string&lt;/span&gt;&lt;/b&gt; output &lt;span style="color: #ff0000"&gt;=&lt;/span&gt; Site&lt;span style="color: #ff0000"&gt;.&lt;/span&gt;PadRight(MaxWidth) &lt;span style="color: #ff0000"&gt;+&lt;/span&gt;&amp;#160;&lt;span style="color: #800000"&gt;&amp;quot;&amp;#160;
&amp;quot;&lt;/span&gt;&amp;#160;&lt;span style="color: #ff0000"&gt;+&lt;/span&gt; www[Site]; 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
Console&lt;span style="color: #ff0000"&gt;.&lt;/span&gt;WriteLine(output); 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
OutputIt(output); 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/L.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
}
&lt;/div&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (ftp&lt;span style="color: #ff0000"&gt;.&lt;/span&gt;Keys&lt;span style="color: #ff0000"&gt;.&lt;/span&gt;Count &lt;span style="color: #ff0000"&gt;&amp;gt;&lt;/span&gt;&amp;#160;&lt;b&gt;&lt;span style="color: #008080"&gt;0&lt;/span&gt;&lt;/b&gt;) 
&lt;br /&gt;
&lt;div id="closed633525973907034726_75" style="display: none"&gt;&lt;img onclick="showHideCodeDiv(&amp;#39;633525973907034726_75&amp;#39;, false)" src="http//blogs.sitedoc.co.uk/img/sc/plus.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;b&gt;&lt;span style="color: #00008b"&gt;{...}&lt;/span&gt;&lt;/b&gt;
&lt;/div&gt;
&lt;div id="open633525973907034726_75" style="display: block"&gt;&lt;img onclick="showHideCodeDiv(&amp;#39;633525973907034726_75&amp;#39;, true)" src="http//blogs.sitedoc.co.uk/img/sc/minus.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
{ 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
OutputIt(&lt;b&gt;&lt;span style="color: #48d1cc"&gt;String&lt;/span&gt;&lt;/b&gt;&lt;span style="color: #ff0000"&gt;.Empty);&lt;/span&gt; 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
OutputIt(&lt;span style="color: #800000"&gt;&amp;quot;FTP&lt;/span&gt;&amp;#160;&lt;span style="color: #800000"&gt;Sites&amp;quot;&lt;/span&gt;); 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
OutputIt(&lt;span style="color: #800000"&gt;&amp;quot;=========&lt;/span&gt;&lt;span style="color: #800000"&gt;&amp;quot;&lt;/span&gt;); 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #0000ff"&gt;foreach&lt;/span&gt; (&lt;b&gt;&lt;span style="color: #0000ff"&gt;string&lt;/span&gt;&lt;/b&gt; Site
in ftp&lt;span style="color: #ff0000"&gt;.&lt;/span&gt;Keys) 
&lt;br /&gt;
&lt;div id="closed633525973907034726_80" style="display: none"&gt;&lt;img onclick="showHideCodeDiv(&amp;#39;633525973907034726_80&amp;#39;, false)" src="http//blogs.sitedoc.co.uk/img/sc/plus.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;b&gt;&lt;span style="color: #00008b"&gt;{...}&lt;/span&gt;&lt;/b&gt;
&lt;/div&gt;
&lt;div id="open633525973907034726_80" style="display: block"&gt;&lt;img onclick="showHideCodeDiv(&amp;#39;633525973907034726_80&amp;#39;, true)" src="http//blogs.sitedoc.co.uk/img/sc/minus.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
{ 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;b&gt;&lt;span style="color: #0000ff"&gt;string&lt;/span&gt;&lt;/b&gt; output &lt;span style="color: #ff0000"&gt;=&lt;/span&gt; Site&lt;span style="color: #ff0000"&gt;.&lt;/span&gt;PadRight(MaxWidth) &lt;span style="color: #ff0000"&gt;+&lt;/span&gt;&amp;#160;&lt;span style="color: #800000"&gt;&amp;quot;&amp;#160;
&amp;quot;&lt;/span&gt;&amp;#160;&lt;span style="color: #ff0000"&gt;+&lt;/span&gt; ftp[Site]; 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
OutputIt(output); 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/L.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
}
&lt;/div&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/L.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
}
&lt;/div&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/L.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
}
&lt;/div&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #3cb371"&gt;//
Catch any errors&lt;/span&gt; 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #0000ff"&gt;catch&lt;/span&gt; (Exception
e) 
&lt;br /&gt;
&lt;div id="closed633525973907034726_88" style="display: none"&gt;&lt;img onclick="showHideCodeDiv(&amp;#39;633525973907034726_88&amp;#39;, false)" src="http//blogs.sitedoc.co.uk/img/sc/plus.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;b&gt;&lt;span style="color: #00008b"&gt;{...}&lt;/span&gt;&lt;/b&gt;
&lt;/div&gt;
&lt;div id="open633525973907034726_88" style="display: block"&gt;&lt;img onclick="showHideCodeDiv(&amp;#39;633525973907034726_88&amp;#39;, true)" src="http//blogs.sitedoc.co.uk/img/sc/minus.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
{ 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
Console&lt;span style="color: #ff0000"&gt;.&lt;/span&gt;WriteLine(&lt;span style="color: #800000"&gt;&amp;quot;Error:&lt;/span&gt;&amp;#160;&lt;span style="color: #800000"&gt;&amp;quot;&lt;/span&gt;&amp;#160;&lt;span style="color: #ff0000"&gt;+&lt;/span&gt; e&lt;span style="color: #ff0000"&gt;.&lt;/span&gt;ToString()); 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/L.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
}
&lt;/div&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #0000ff"&gt;finally&lt;/span&gt; 
&lt;br /&gt;
&lt;div id="closed633525973907034726_92" style="display: none"&gt;&lt;img onclick="showHideCodeDiv(&amp;#39;633525973907034726_92&amp;#39;, false)" src="http//blogs.sitedoc.co.uk/img/sc/plus.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;b&gt;&lt;span style="color: #00008b"&gt;{...}&lt;/span&gt;&lt;/b&gt;
&lt;/div&gt;
&lt;div id="open633525973907034726_92" style="display: block"&gt;&lt;img onclick="showHideCodeDiv(&amp;#39;633525973907034726_92&amp;#39;, true)" src="http//blogs.sitedoc.co.uk/img/sc/minus.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
{ 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
Console&lt;span style="color: #ff0000"&gt;.&lt;/span&gt;WriteLine(); 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
Console&lt;span style="color: #ff0000"&gt;.&lt;/span&gt;WriteLine(&lt;span style="color: #800000"&gt;&amp;quot;Press&lt;/span&gt;&amp;#160;&lt;span style="color: #800000"&gt;enter
to close/exit...&amp;quot;&lt;/span&gt;); 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #3cb371"&gt;//Console.Read();&lt;/span&gt; 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/L.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
}
&lt;/div&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/L.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
}
&lt;/div&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /&gt; 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt;&amp;#160;&lt;b&gt;&lt;span style="color: #0000ff"&gt;void&lt;/span&gt;&lt;/b&gt; OutputIt(&lt;b&gt;&lt;span style="color: #0000ff"&gt;string&lt;/span&gt;&lt;/b&gt; lineToAdd) 
&lt;br /&gt;
&lt;div id="closed633525973907034726_100" style="display: none"&gt;&lt;img onclick="showHideCodeDiv(&amp;#39;633525973907034726_100&amp;#39;, false)" src="http//blogs.sitedoc.co.uk/img/sc/plus.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;b&gt;&lt;span style="color: #00008b"&gt;{...}&lt;/span&gt;&lt;/b&gt;
&lt;/div&gt;
&lt;div id="open633525973907034726_100" style="display: block"&gt;&lt;img onclick="showHideCodeDiv(&amp;#39;633525973907034726_100&amp;#39;, true)" src="http//blogs.sitedoc.co.uk/img/sc/minus.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
{ 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
Console&lt;span style="color: #ff0000"&gt;.&lt;/span&gt;WriteLine(lineToAdd); 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /&gt; 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (&lt;span style="color: #ff0000"&gt;!&lt;/span&gt;&lt;b&gt;&lt;span style="color: #48d1cc"&gt;String&lt;/span&gt;&lt;/b&gt;&lt;span style="color: #ff0000"&gt;.&lt;/span&gt;IsNullOrEmpty(fileToWrite)) 
&lt;br /&gt;
&lt;div id="closed633525973907034726_104" style="display: none"&gt;&lt;img onclick="showHideCodeDiv(&amp;#39;633525973907034726_104&amp;#39;, false)" src="http//blogs.sitedoc.co.uk/img/sc/plus.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;b&gt;&lt;span style="color: #00008b"&gt;{...}&lt;/span&gt;&lt;/b&gt;
&lt;/div&gt;
&lt;div id="open633525973907034726_104" style="display: block"&gt;&lt;img onclick="showHideCodeDiv(&amp;#39;633525973907034726_104&amp;#39;, true)" src="http//blogs.sitedoc.co.uk/img/sc/minus.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
{ 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
StreamWriter SW; 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
SW &lt;span style="color: #ff0000"&gt;=&lt;/span&gt; File&lt;span style="color: #ff0000"&gt;.&lt;/span&gt;AppendText(fileToWrite); 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
SW&lt;span style="color: #ff0000"&gt;.&lt;/span&gt;WriteLine(lineToAdd); 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
SW&lt;span style="color: #ff0000"&gt;.&lt;/span&gt;Close(); 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/L.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
}
&lt;/div&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #0000ff"&gt;else&lt;/span&gt; 
&lt;br /&gt;
&lt;div id="closed633525973907034726_111" style="display: none"&gt;&lt;img onclick="showHideCodeDiv(&amp;#39;633525973907034726_111&amp;#39;, false)" src="http//blogs.sitedoc.co.uk/img/sc/plus.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;b&gt;&lt;span style="color: #00008b"&gt;{...}&lt;/span&gt;&lt;/b&gt;
&lt;/div&gt;
&lt;div id="open633525973907034726_111" style="display: block"&gt;&lt;img onclick="showHideCodeDiv(&amp;#39;633525973907034726_111&amp;#39;, true)" src="http//blogs.sitedoc.co.uk/img/sc/minus.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
{ 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/I.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
Console&lt;span style="color: #ff0000"&gt;.&lt;/span&gt;WriteLine(&lt;span style="color: #800000"&gt;&amp;quot;locationToOutput&lt;/span&gt;&amp;#160;&lt;span style="color: #800000"&gt;is
Null or String.Empty please supply a value and try again.&amp;quot;&lt;/span&gt;); 
&lt;br /&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/L.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
}
&lt;/div&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/L.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;
}
&lt;/div&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/L.gif" align="top" /&gt;&amp;#160;&amp;#160;&amp;#160;
}
&lt;/div&gt;
&lt;img src="http//blogs.sitedoc.co.uk/img/sc/L.gif" align="top" /&gt;}
&lt;/div&gt;
&lt;/div&gt;
&lt;img width="0" height="0" src="http://blogs.thesitedoctor.co.uk/tim/aggbug.ashx?id=7d30dc6f-8135-41f6-bb00-5be6f0162d70" /&gt;</description>
      <comments>http://blogs.thesitedoctor.co.uk/tim/CommentView,guid,7d30dc6f-8135-41f6-bb00-5be6f0162d70.aspx</comments>
      <category>C#</category>
      <category>IIS</category>
      <category>Server Management</category>
      <category>The Site Doctor</category>
      <category>Web Development</category>
    </item>
    <item>
      <trackback:ping>http://blogs.thesitedoctor.co.uk/tim/Trackback.aspx?guid=4b25e0a2-9f4e-4abf-abd2-621a7a1d848f</trackback:ping>
      <pingback:server>http://blogs.thesitedoctor.co.uk/tim/pingback.aspx</pingback:server>
      <pingback:target>http://blogs.thesitedoctor.co.uk/tim/PermaLink,guid,4b25e0a2-9f4e-4abf-abd2-621a7a1d848f.aspx</pingback:target>
      <dc:creator>Tim</dc:creator>
      <wfw:comment>http://blogs.thesitedoctor.co.uk/tim/CommentView,guid,4b25e0a2-9f4e-4abf-abd2-621a7a1d848f.aspx</wfw:comment>
      <wfw:commentRss>http://blogs.thesitedoctor.co.uk/tim/SyndicationService.asmx/GetEntryCommentsRss?guid=4b25e0a2-9f4e-4abf-abd2-621a7a1d848f</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <a href="http://www.27seconds.com/">Doug Setzer</a> posted this comment in response
to my recent "<a href="http://blogs.thesitedoctor.co.uk/tim/2008/05/28/A+Seriously+Elegant+SQL+Injection.aspx">A
seriously elegant SQL Injection</a>" post and I thought it may be of interest to others
so have promoted it to a post...
</p>
        <hr />
        <p>
Well, I'll step up and say that I am the "mate" who had this done.  Tim's right
- *always* sanitize your inputs.  In my defence, this was a site that I inherited
from a previous contractor.  I'm not entirely absent of blame, I still should
have done a security sweep through the code.
</p>
        <p>
I'd like to document the steps that I went through once this was identified to try
and avoid this kind of thing in the future.
</p>
        <ol>
          <li>
Edit every web page that executes a query to sanitize any parameters that are passed
in.  Since the site was classic ASP, I used my "SQLStringFieldValue" function:<br /><a href="http://www.27seconds.com/kb/article_view.aspx?id=50">www.27seconds.com/kb/article_view.aspx?id=50</a></li>
          <li>
Modify the DB user account that is used to have *read only* access to the database 
</li>
          <li>
Modify the pages that DO write to the database to have *read/write* access to the
specific tables that are being changed.  This limits the number of places that
SQL Injection can occur to a smaller set than was previously possible.  I still
sanitize all of my input, but I'm extra spastic in these database calls. 
</li>
          <li>
Add database auditing (triggers writing to mirror tables with audit event indicator
&amp; date/time) to see when data changes occur.  This is still problematic with
the pages that have "write" permissions to the tables, but again- that footprint is
much smaller.</li>
        </ol>
        <ol>
My future plans are to move to a view/stored procedure based architecture.  I
can then limit write permissions to just the stored procedures and read permissions
to just the views.  My grand gusto plans are to move to using command objects
&amp; parameters, but I'd sooner re-write the entire site.
</ol>
        <hr />
        <p>
Although Doug's attack wasn't the same nihaorr1.com attack that's going around atm
it was similar so I would imagine other's will find this useful.
</p>
        <p>
It still amazes me how many developers still fail to sanitise strings, only last week
I came across another site (in PHP) that was allowing simple SQL injections to be
used to log into their administration system. It was down to a problem with the sanitization
string, but why not at least check your site before it goes live? It takes 2 minutes
and even less to fix...
</p>
        <p>
For those of you who need a few pointers, there's a good discussion or two about <a href="http://www.aspmessageboard.com/forum/asp.asp?M=896001&amp;T=896001&amp;F=20&amp;P=1#896004">sanitising
strings on the 4 Guys From Rolla site</a>.
</p>
        <img width="0" height="0" src="http://blogs.thesitedoctor.co.uk/tim/aggbug.ashx?id=4b25e0a2-9f4e-4abf-abd2-621a7a1d848f" />
      </body>
      <title>A seriously elegant SQL Injection -how it was sorted</title>
      <guid isPermaLink="false">http://blogs.thesitedoctor.co.uk/tim/PermaLink,guid,4b25e0a2-9f4e-4abf-abd2-621a7a1d848f.aspx</guid>
      <link>http://blogs.thesitedoctor.co.uk/tim/2008/05/29/A+Seriously+Elegant+SQL+Injection+How+It+Was+Sorted.aspx</link>
      <pubDate>Thu, 29 May 2008 14:32:33 GMT</pubDate>
      <description>&lt;p&gt;
&lt;a href="http://www.27seconds.com/"&gt;Doug Setzer&lt;/a&gt; posted this comment in response
to my recent "&lt;a href="http://blogs.thesitedoctor.co.uk/tim/2008/05/28/A+Seriously+Elegant+SQL+Injection.aspx"&gt;A
seriously elegant SQL Injection&lt;/a&gt;" post and I thought it may be of interest to others
so have promoted it to a post...
&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;
Well, I'll step up and say that I am the "mate" who had this done.&amp;nbsp; Tim's right
- *always* sanitize your inputs.&amp;nbsp; In my defence, this was a site that I inherited
from a previous contractor.&amp;nbsp; I'm not entirely absent of blame, I still should
have done a security sweep through the code.
&lt;/p&gt;
&lt;p&gt;
I'd like to document the steps that I went through once this was identified to try
and avoid this kind of thing in the future.
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
Edit every web page that executes a query to sanitize any parameters that are passed
in.&amp;nbsp; Since the site was classic ASP, I used my "SQLStringFieldValue" function:&lt;br&gt;
&lt;a href="http://www.27seconds.com/kb/article_view.aspx?id=50"&gt;www.27seconds.com/kb/article_view.aspx?id=50&lt;/a&gt; 
&lt;li&gt;
Modify the DB user account that is used to have *read only* access to the database 
&lt;li&gt;
Modify the pages that DO write to the database to have *read/write* access to the
specific tables that are being changed.&amp;nbsp; This limits the number of places that
SQL Injection can occur to a smaller set than was previously possible.&amp;nbsp; I still
sanitize all of my input, but I'm extra spastic in these database calls. 
&lt;li&gt;
Add database auditing (triggers writing to mirror tables with audit event indicator
&amp;amp; date/time) to see when data changes occur.&amp;nbsp; This is still problematic with
the pages that have "write" permissions to the tables, but again- that footprint is
much smaller.&lt;/li&gt;
&lt;/ol&gt;
&lt;ol&gt;
My future plans are to move to a view/stored procedure based architecture.&amp;nbsp; I
can then limit write permissions to just the stored procedures and read permissions
to just the views.&amp;nbsp; My grand gusto plans are to move to using command objects
&amp;amp; parameters, but I'd sooner re-write the entire site.
&lt;/ol&gt;
&lt;hr&gt;
&lt;p&gt;
Although Doug's attack wasn't the same nihaorr1.com attack that's going around atm
it was similar so I would imagine other's will find this useful.
&lt;/p&gt;
&lt;p&gt;
It still amazes me how many developers still fail to sanitise strings, only last week
I came across another site (in PHP) that was allowing simple SQL injections to be
used to log into their administration system. It was down to a problem with the sanitization
string, but why not at least check your site before it goes live? It takes 2 minutes
and even less to fix...
&lt;/p&gt;
&lt;p&gt;
For those of you who need a few pointers, there's a good discussion or two about &lt;a href="http://www.aspmessageboard.com/forum/asp.asp?M=896001&amp;amp;T=896001&amp;amp;F=20&amp;amp;P=1#896004"&gt;sanitising
strings on the 4 Guys From Rolla site&lt;/a&gt;.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blogs.thesitedoctor.co.uk/tim/aggbug.ashx?id=4b25e0a2-9f4e-4abf-abd2-621a7a1d848f" /&gt;</description>
      <comments>http://blogs.thesitedoctor.co.uk/tim/CommentView,guid,4b25e0a2-9f4e-4abf-abd2-621a7a1d848f.aspx</comments>
      <category>ASP</category>
      <category>ASP.Net</category>
      <category>C#</category>
      <category>Development</category>
      <category>IIS</category>
      <category>Security</category>
      <category>SQL Server</category>
      <category>Web Development</category>
    </item>
    <item>
      <trackback:ping>http://blogs.thesitedoctor.co.uk/tim/Trackback.aspx?guid=f1e53961-7c8c-4f1e-90fa-b0d04c1e669d</trackback:ping>
      <pingback:server>http://blogs.thesitedoctor.co.uk/tim/pingback.aspx</pingback:server>
      <pingback:target>http://blogs.thesitedoctor.co.uk/tim/PermaLink,guid,f1e53961-7c8c-4f1e-90fa-b0d04c1e669d.aspx</pingback:target>
      <dc:creator>Tim</dc:creator>
      <wfw:comment>http://blogs.thesitedoctor.co.uk/tim/CommentView,guid,f1e53961-7c8c-4f1e-90fa-b0d04c1e669d.aspx</wfw:comment>
      <wfw:commentRss>http://blogs.thesitedoctor.co.uk/tim/SyndicationService.asmx/GetEntryCommentsRss?guid=f1e53961-7c8c-4f1e-90fa-b0d04c1e669d</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
As with my previous post, we upgraded the AJAX framework on the weekend which broke
a few things, but one control in particular that broke was our TextChangedTextBox
which is based on Pete Kellner's timed postback control. Since updating we were receiving
a "'debug' is undefined" error on line 1409 (which was in one of the JavaScript include
files).
</p>
        <p>
Having had this issue before I updated the TextChangedBehavior.js but that didn't
sort it, I have the latest version of the Futures on the server too so I was lost.
Turns out I had an old version of the AJAX Futures DLL within the Bin folder of the
project.
</p>
        <p>
So as with my post on the ASP.Net forums before -make sure you update your AJAX Futures
when updating your Microsoft AJAX framework!
</p>
        <img width="0" height="0" src="http://blogs.thesitedoctor.co.uk/tim/aggbug.ashx?id=f1e53961-7c8c-4f1e-90fa-b0d04c1e669d" />
      </body>
      <title>'debug' is undefined with Microsoft AJAX release and TextChangedBehavior.js</title>
      <guid isPermaLink="false">http://blogs.thesitedoctor.co.uk/tim/PermaLink,guid,f1e53961-7c8c-4f1e-90fa-b0d04c1e669d.aspx</guid>
      <link>http://blogs.thesitedoctor.co.uk/tim/2007/08/08/debug+Is+Undefined+With+Microsoft+AJAX+Release+And+TextChangedBehaviorjs.aspx</link>
      <pubDate>Wed, 08 Aug 2007 05:20:47 GMT</pubDate>
      <description>&lt;p&gt;
As with my previous post, we upgraded the AJAX framework on the weekend which broke
a few things, but one control in particular that broke was our TextChangedTextBox
which is based on Pete Kellner's timed postback control. Since updating we were receiving
a "'debug' is undefined" error on line 1409 (which was in one of the JavaScript include
files).
&lt;/p&gt;
&lt;p&gt;
Having had this issue before I updated the TextChangedBehavior.js but that didn't
sort it, I have the latest version of the Futures on the server too so I was lost.
Turns out I had an old version of the AJAX Futures DLL within the Bin folder of the
project.
&lt;/p&gt;
&lt;p&gt;
So as with my post on the ASP.Net forums before -make sure you update your AJAX Futures
when updating your Microsoft AJAX framework!
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blogs.thesitedoctor.co.uk/tim/aggbug.ashx?id=f1e53961-7c8c-4f1e-90fa-b0d04c1e669d" /&gt;</description>
      <comments>http://blogs.thesitedoctor.co.uk/tim/CommentView,guid,f1e53961-7c8c-4f1e-90fa-b0d04c1e669d.aspx</comments>
      <category>AJAX</category>
      <category>ASP.Net</category>
      <category>IIS</category>
      <category>The Site Doctor</category>
      <category>Web Development</category>
      <category>WebDD</category>
    </item>
    <item>
      <trackback:ping>http://blogs.thesitedoctor.co.uk/tim/Trackback.aspx?guid=16154838-1f51-4566-b1f2-0023536df4cd</trackback:ping>
      <pingback:server>http://blogs.thesitedoctor.co.uk/tim/pingback.aspx</pingback:server>
      <pingback:target>http://blogs.thesitedoctor.co.uk/tim/PermaLink,guid,16154838-1f51-4566-b1f2-0023536df4cd.aspx</pingback:target>
      <dc:creator>Tim</dc:creator>
      <wfw:comment>http://blogs.thesitedoctor.co.uk/tim/CommentView,guid,16154838-1f51-4566-b1f2-0023536df4cd.aspx</wfw:comment>
      <wfw:commentRss>http://blogs.thesitedoctor.co.uk/tim/SyndicationService.asmx/GetEntryCommentsRss?guid=16154838-1f51-4566-b1f2-0023536df4cd</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
When we got our own dedicated server we needed to start working out a fair number
of processes and decide upon a structure that was replicable, scaleable and manageable
on a large scale, although the solution we've ended up adopting may not be the best,
it certainly works for us. 
</p>
        <p>
One thing that has been bugging me however is the location and folder naming convention
of the log files -for both the web hits and FTP hits. Typically, shared hosting solutions
place the log files under the same folder as the one your website's root is situated
but as we had no plans on giving our clients access to these logs this was an unnecessary
task so we left them collecting in the default folder. 
</p>
        <p>
Leaving the log files in the default folder meant downloading them was very simple,
all I needed to do was point our download script at the main folder and that was it,
all would be included, the catch however was that the folders weren't named logically*
instead they seemed to include some form of ID that was relevant to and assigned by
IIS i.e. W3SVC1. 
</p>
        <p>
*By this I mean human readable i.e. domainname.com 
</p>
        <p>
Until recently I've not worried about analysing the log files beyond one or two clients
whom I could manage fairly easily but now with the inclusion of a host of other domains
on the server I needed a way of quickly and easily identifying the folders and which
domains they related to. 
</p>
        <p>
Historically when I needed to know which domain the log folder related to I would
log onto the server, open IIS, open the properties of the domain, click on the log
file properties and below the folder directory would be the folder name, that's fine
if it's only a handful of domains but what when it's say 20? That's 2mins each (with
cross referencing etc) so that's 40minutes. I needed an automated system! 
</p>
        <p>
As it turns out, Microsoft have been kind enough to provide us with an interface we
can easily code against in .Net so after a little Google-ing I wrote a number of little
helper applications. 
</p>
        <p>
          <a title="IIS WWW and FTP log file location exporter" href="http://blogs.thesitedoctor.co.uk/tim/files/iissites_v1.zip">This
little console application</a> simply loops through all the domain names on the server
it's being run on (the default instance of IIS) and outputs the relevant log file
and folder path into a handy text file. I'll post in another post about how I
use this file. 
</p>
        <p>
For convenience's sake I have this run on a nightly basis and the text file output
to the root of the log file directory, that way when I download the logs during the
next day I get the latest update of log file locations and domain names :) 
</p>
        <p>
          <a title="IIS WWW and FTP log file location exporter" href="http://blogs.thesitedoctor.co.uk/tim/files/iissites_v1.zip">Download
the IIS WWW and FTP log file location exporter</a>.
</p>
        <p>
          <b>1 Year Update:</b> I've posted the <a href="http://blogs.thesitedoctor.co.uk/tim/2008/07/25/Identify+IIS+Sites+And+Log+File+Locations+For+WWW+And+FTP+Ndashthe+Source.aspx">source
for the IIS WWW and FTP log file location exporter here</a>.<br /></p>
        <img width="0" height="0" src="http://blogs.thesitedoctor.co.uk/tim/aggbug.ashx?id=16154838-1f51-4566-b1f2-0023536df4cd" />
      </body>
      <title>Identify IIS Sites and Log File locations for WWW and FTP</title>
      <guid isPermaLink="false">http://blogs.thesitedoctor.co.uk/tim/PermaLink,guid,16154838-1f51-4566-b1f2-0023536df4cd.aspx</guid>
      <link>http://blogs.thesitedoctor.co.uk/tim/2007/07/25/Identify+IIS+Sites+And+Log+File+Locations+For+WWW+And+FTP.aspx</link>
      <pubDate>Wed, 25 Jul 2007 15:18:42 GMT</pubDate>
      <description>&lt;p&gt;
When we got our own dedicated server we needed to start working out a fair number
of processes and decide upon a structure that was replicable, scaleable and manageable
on a large scale, although the solution we've ended up adopting may not be the best,
it certainly works for us. 
&lt;/p&gt;
&lt;p&gt;
One thing that has been bugging me however is the location and folder naming convention
of the log files -for both the web hits and FTP hits. Typically, shared hosting solutions
place the log files under the same folder as the one your website's root is situated
but as we had no plans on giving our clients access to these logs this was an unnecessary
task so we left them collecting in the default folder. 
&lt;/p&gt;
&lt;p&gt;
Leaving the log files in the default folder meant downloading them was very simple,
all I needed to do was point our download script at the main folder and that was it,
all would be included, the catch however was that the folders weren't named logically*
instead they seemed to include some form of ID that was relevant to and assigned by
IIS i.e. W3SVC1. 
&lt;/p&gt;
&lt;p&gt;
*By this I mean human readable i.e. domainname.com 
&lt;/p&gt;
&lt;p&gt;
Until recently I've not worried about analysing the log files beyond one or two clients
whom I could manage fairly easily but now with the inclusion of a host of other domains
on the server I needed a way of quickly and easily identifying the folders and which
domains they related to. 
&lt;/p&gt;
&lt;p&gt;
Historically when I needed to know which domain the log folder related to I would
log onto the server, open IIS, open the properties of the domain, click on the log
file properties and below the folder directory would be the folder name, that's fine
if it's only a handful of domains but what when it's say 20? That's 2mins each (with
cross referencing etc) so that's 40minutes. I needed an automated system! 
&lt;/p&gt;
&lt;p&gt;
As it turns out, Microsoft have been kind enough to provide us with an interface we
can easily code against in .Net so after a little Google-ing I wrote a number of little
helper applications. 
&lt;/p&gt;
&lt;p&gt;
&lt;a title="IIS WWW and FTP log file location exporter" href="http://blogs.thesitedoctor.co.uk/tim/files/iissites_v1.zip"&gt;This
little console application&lt;/a&gt; simply loops through all the domain names on the server
it's being run on (the default instance of IIS) and outputs the relevant log file
and folder path into a handy text file. I'll post&amp;nbsp;in another post about how I
use this file. 
&lt;/p&gt;
&lt;p&gt;
For convenience's sake I have this run on a nightly basis and the text file output
to the root of the log file directory, that way when I download the logs during the
next day I get the latest update of log file locations and domain names :) 
&lt;/p&gt;
&lt;p&gt;
&lt;a title="IIS WWW and FTP log file location exporter" href="http://blogs.thesitedoctor.co.uk/tim/files/iissites_v1.zip"&gt;Download
the IIS WWW and FTP log file location exporter&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
&lt;b&gt;1 Year Update:&lt;/b&gt; I've posted the &lt;a href="http://blogs.thesitedoctor.co.uk/tim/2008/07/25/Identify+IIS+Sites+And+Log+File+Locations+For+WWW+And+FTP+Ndashthe+Source.aspx"&gt;source
for the IIS WWW and FTP log file location exporter here&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blogs.thesitedoctor.co.uk/tim/aggbug.ashx?id=16154838-1f51-4566-b1f2-0023536df4cd" /&gt;</description>
      <comments>http://blogs.thesitedoctor.co.uk/tim/CommentView,guid,16154838-1f51-4566-b1f2-0023536df4cd.aspx</comments>
      <category>IIS</category>
      <category>Server Management</category>
      <category>The Site Doctor</category>
      <category>Web Development</category>
      <category>WebDD</category>
    </item>
    <item>
      <trackback:ping>http://blogs.thesitedoctor.co.uk/tim/Trackback.aspx?guid=3acf5fd8-3644-4944-a1d0-4928c79abd96</trackback:ping>
      <pingback:server>http://blogs.thesitedoctor.co.uk/tim/pingback.aspx</pingback:server>
      <pingback:target>http://blogs.thesitedoctor.co.uk/tim/PermaLink,guid,3acf5fd8-3644-4944-a1d0-4928c79abd96.aspx</pingback:target>
      <dc:creator>Tim</dc:creator>
      <wfw:comment>http://blogs.thesitedoctor.co.uk/tim/CommentView,guid,3acf5fd8-3644-4944-a1d0-4928c79abd96.aspx</wfw:comment>
      <wfw:commentRss>http://blogs.thesitedoctor.co.uk/tim/SyndicationService.asmx/GetEntryCommentsRss?guid=3acf5fd8-3644-4944-a1d0-4928c79abd96</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Another post from <span class="vcard"><a href="http://www.27seconds.com/" rel="friend" class="url n fn"><span class="givenname">Doug</span><span class="family-name">Setzer</span></a></span> from <a href="http://www.27Seconds.com/">27Seconds.com</a> :) 
</p>
        <hr />
        <p>
At my "day job", the systems guys are building new Windows 2003 servers
to upgrade our aging Windows 2000 servers.  The plan is to:<br />
 - Build the new Windows 2003 server<br />
 - Install IIS<br />
 - Install .NET<br />
 - Run the IIS migration tool from the old Win2k server
</p>
        <p>
That all went as well as could go - little things got mixed up and had to be corrected. 
But, the server would let you request plain HTML files and ASPX files, but classic
ASP pages were returned blank.  In poking around Google and the server, we came
to find that we had to enable ASP content via: 
<br />
 - IIS Manager<br />
 - Web Services Extensions<br />
 - Specifically allow Active Server Pages
</p>
        <p>
But, we were still having the same issues.  Stopping and restarting IIS didn't
help. Nor did a server reboot.
</p>
        <p>
I found a blog post that mentioned checking that the ASP ISAPI has the correct path. 
It tried a random thought that Microsoft has changed the default name of the "Windows"/"Winnt"
folder -- Windows NT4, 2000, etc. all use "Winnt", where as Windows 2003
uses the "Windows" folder.  Sure enough, double checking the path to
the ASP ISAPI had the wrong path and fixing this path fixed our issues with classic
ASP files. 
</p>
        <img width="0" height="0" src="http://blogs.thesitedoctor.co.uk/tim/aggbug.ashx?id=3acf5fd8-3644-4944-a1d0-4928c79abd96" />
      </body>
      <title>ASP not running on Windows 2003 with ASP.Net installed</title>
      <guid isPermaLink="false">http://blogs.thesitedoctor.co.uk/tim/PermaLink,guid,3acf5fd8-3644-4944-a1d0-4928c79abd96.aspx</guid>
      <link>http://blogs.thesitedoctor.co.uk/tim/2007/03/12/ASP+Not+Running+On+Windows+2003+With+ASPNet+Installed.aspx</link>
      <pubDate>Mon, 12 Mar 2007 10:49:09 GMT</pubDate>
      <description>&lt;p&gt;
Another post from &lt;span class="vcard"&gt;&lt;a href="http://www.27seconds.com/" rel="friend" class="url n fn"&gt;&lt;span class="givenname"&gt;Doug&lt;/span&gt; &lt;span class="family-name"&gt;Setzer&lt;/span&gt;&lt;/a&gt;&lt;/span&gt; from &lt;a href="http://www.27Seconds.com/"&gt;27Seconds.com&lt;/a&gt; :) 
&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;
At my &amp;quot;day job&amp;quot;, the systems guys are building new Windows 2003 servers
to upgrade our aging Windows 2000 servers.&amp;nbsp; The plan is to:&lt;br /&gt;
&amp;nbsp;- Build the new Windows 2003 server&lt;br /&gt;
&amp;nbsp;- Install IIS&lt;br /&gt;
&amp;nbsp;- Install .NET&lt;br /&gt;
&amp;nbsp;- Run the IIS migration tool from the old Win2k server
&lt;/p&gt;
&lt;p&gt;
That all went as well as could go - little things got mixed up and had to be corrected.&amp;nbsp;
But, the server would let you request plain HTML files and ASPX files, but classic
ASP pages were returned blank.&amp;nbsp; In poking around Google and the server, we came
to find that we had to enable ASP content via: 
&lt;br /&gt;
&amp;nbsp;- IIS Manager&lt;br /&gt;
&amp;nbsp;- Web Services Extensions&lt;br /&gt;
&amp;nbsp;- Specifically allow Active Server Pages
&lt;/p&gt;
&lt;p&gt;
But, we were still having the same issues.&amp;nbsp; Stopping and restarting IIS didn't
help. Nor did a server reboot.
&lt;/p&gt;
&lt;p&gt;
I found a blog post that mentioned checking that the ASP ISAPI has the correct path.&amp;nbsp;
It tried a random thought that Microsoft has changed the default name of the &amp;quot;Windows&amp;quot;/&amp;quot;Winnt&amp;quot;
folder -- Windows NT4, 2000, etc. all use &amp;quot;Winnt&amp;quot;, where as Windows 2003
uses the &amp;quot;Windows&amp;quot; folder.&amp;nbsp; Sure enough, double checking the path to
the ASP ISAPI had the wrong path and fixing this path fixed our issues with classic
ASP files. 
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blogs.thesitedoctor.co.uk/tim/aggbug.ashx?id=3acf5fd8-3644-4944-a1d0-4928c79abd96" /&gt;</description>
      <comments>http://blogs.thesitedoctor.co.uk/tim/CommentView,guid,3acf5fd8-3644-4944-a1d0-4928c79abd96.aspx</comments>
      <category>ASP</category>
      <category>ASP.Net</category>
      <category>IIS</category>
      <category>Web Development</category>
    </item>
    <item>
      <trackback:ping>http://blogs.thesitedoctor.co.uk/tim/Trackback.aspx?guid=9d04c0af-248a-487e-b8d7-0b4bc8b8f6a1</trackback:ping>
      <pingback:server>http://blogs.thesitedoctor.co.uk/tim/pingback.aspx</pingback:server>
      <pingback:target>http://blogs.thesitedoctor.co.uk/tim/PermaLink,guid,9d04c0af-248a-487e-b8d7-0b4bc8b8f6a1.aspx</pingback:target>
      <dc:creator>Tim</dc:creator>
      <wfw:comment>http://blogs.thesitedoctor.co.uk/tim/CommentView,guid,9d04c0af-248a-487e-b8d7-0b4bc8b8f6a1.aspx</wfw:comment>
      <wfw:commentRss>http://blogs.thesitedoctor.co.uk/tim/SyndicationService.asmx/GetEntryCommentsRss?guid=9d04c0af-248a-487e-b8d7-0b4bc8b8f6a1</wfw:commentRss>
      <slash:comments>12</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
This is a really useful little VBS script that I’ve been meaning to post for a while
now (along with a couple of other little applications I’ve written for log file analysis).
I don’t think I wrote this script but at the same time can’t recall where it came
from.
</p>
        <p>
It basically traverses the 
<abbr title="Filesystem Object">
FSO
</abbr>
finding files with the designated extension and assuming the match the standard IIS
date format, checks whether they’re older than x days, if they are deletes them. Running
it is simple, place somewhere obvious on the server and just double click it. Alternatively
if you want to read the output, run it from CMD. For safety’s sake, the first time
you run it I would leave it just printing out the files that will be deleted.
</p>
        <p>
Personally I don’t schedule this script as although automation is great, I’ll probably
have it delete the logs before I’ve had a chance to download them so what I tend to
do is download the logs and then after that (or the next time I’m on 
<abbr title="Remote Desktop Connection">
RDC
</abbr>
) I run it, I find that way I ensure I get all the log files i.e. if I go on holiday.
</p>
        <p>
I’ve got two other applications that I’ll post shortly, one outputs the location of
the log files for each domain name within IIS and the other combines the log files
into one for analysis –it also takes the exported file/folder locations and names
the combined log files with the domain’s name –saves a ton of time!
</p>
        <p>
          <a title="Download the ZIP file containing the VBS script" href="/tim/files/deletelogfiles.zip">Download
the VBS script as a ZIP file</a>
        </p>
        <div class="code">
          <img alt="" src="/img/sc/clear.gif" align="top" />
          <b>
            <span style="color: #0000ff">Option</span>
          </b> <b><span style="color: #0000ff">Explicit</span></b><br /><img alt="" src="/img/sc/clear.gif" align="top" /><br /><img alt="" src="/img/sc/clear.gif" align="top" /><b><span style="color: #0000ff">Dim</span></b> intDaysOld<span style="color: #ff0000">,</span> strObjTopFolderPath<span style="color: #ff0000">,</span> strLogFIleSuffix<span style="color: #ff0000">,</span> ObjFS<span style="color: #ff0000">,</span> ObjTopFolder <br /><img alt="" src="/img/sc/clear.gif" align="top" /><b><span style="color: #0000ff">Dim</span></b> ObjDomainFolder<span style="color: #ff0000">,</span> ObjW3SvcFolder<span style="color: #ff0000">,</span> ObjSubFolder<span style="color: #ff0000">,</span> ObjLogFile<span style="color: #ff0000">,</span> ObjFile<br /><img alt="" src="/img/sc/clear.gif" align="top" /><br /><img alt="" src="/img/sc/clear.gif" align="top" />intDaysOld        <span style="color: #ff0000">=</span> <b><span style="color: #008080">5</span></b>        <span style="color: #008000">'</span><span style="color: #008000">Number</span> <span style="color: #008000">of days to retain on the server</span><br /><img alt="" src="/img/sc/clear.gif" align="top" />strObjTopFolderPath    <span style="color: #ff0000">=</span> <span style="color: #4682b4">""</span>        <span style="color: #008000">'The</span> <span style="color: #008000">location of your log files</span><br /><img alt="" src="/img/sc/clear.gif" align="top" />strLogFIleSuffix    <span style="color: #ff0000">=</span> <span style="color: #4682b4">".log"</span>    <span style="color: #008000">'The suffix</span> <span style="color: #008000">of your log files</span><br /><img alt="" src="/img/sc/clear.gif" align="top" /><br /><img alt="" src="/img/sc/clear.gif" align="top" /><b><span style="color: #0000ff">Set</span></b> ObjFS <span style="color: #ff0000">=</span> <span style="color: #ff0000">CreateObject(</span><span style="color: #4682b4">"Scripting.FileSystemObject</span><span style="color: #4682b4">"</span><span style="color: #ff0000">)</span><br /><img alt="" src="/img/sc/clear.gif" align="top" /><b><span style="color: #0000ff">Set</span></b> ObjTopFolder <span style="color: #ff0000">=</span> ObjFS<span style="color: #ff0000">.</span><span style="color: #ff0000">GetFolder(</span>strObjTopFolderPath<span style="color: #ff0000">)</span><br /><img alt="" src="/img/sc/clear.gif" align="top" /><br /><img alt="" src="/img/sc/clear.gif" align="top" /><b><span style="color: #0000ff">For</span></b> <b><span style="color: #0000ff">Each</span></b> ObjDomainFolder in ObjTopFolder<span style="color: #ff0000">.</span>SubFolders<br /><img alt="" src="/img/sc/clear.gif" align="top" />WScript<span style="color: #ff0000">.</span><span style="color: #ff0000">Echo(</span><span style="color: #4682b4">"Folder:</span> <span style="color: #4682b4">"</span> &amp; ObjDomainFolder<span style="color: #ff0000">.</span>name<span style="color: #ff0000">)</span><br /><img alt="" src="/img/sc/clear.gif" align="top" />    <b><span style="color: #0000ff">For</span></b> <b><span style="color: #0000ff">Each</span></b> ObjW3SvcFolder in ObjDomainFolder<span style="color: #ff0000">.</span>SubFolders<br /><img alt="" src="/img/sc/clear.gif" align="top" />        WScript<span style="color: #ff0000">.</span><span style="color: #ff0000">Echo(</span><span style="color: #4682b4">"  Folder:</span> <span style="color: #4682b4">"</span> &amp; ObjW3SvcFolder<span style="color: #ff0000">.</span>name<span style="color: #ff0000">)</span><br /><img alt="" src="/img/sc/clear.gif" align="top" />        <b><span style="color: #0000ff">Set</span></b> ObjSubFolder <span style="color: #ff0000">=</span> ObjFS<span style="color: #ff0000">.</span><span style="color: #ff0000">GetFolder(</span>ObjW3SvcFolder<span style="color: #ff0000">)</span><br /><img alt="" src="/img/sc/clear.gif" align="top" />            <b><span style="color: #0000ff">For</span></b> each ObjLogFile in ObjSubFolder<span style="color: #ff0000">.</span>files<br /><img alt="" src="/img/sc/clear.gif" align="top" />                <b><span style="color: #0000ff">Set</span></b> ObjFile <span style="color: #ff0000">=</span> ObjFS<span style="color: #ff0000">.</span><span style="color: #ff0000">GetFile(</span>ObjLogFile<span style="color: #ff0000">)</span><br /><img alt="" src="/img/sc/clear.gif" align="top" />                <b><span style="color: #0000ff">If</span></b> datediff<span style="color: #ff0000">(</span><span style="color: #4682b4">"d"</span><span style="color: #ff0000">,</span>ObjFile<span style="color: #ff0000">.</span><span style="color: #ff00ff">DateLastModified</span><span style="color: #ff0000">,</span><b><span style="color: #00008b">Date</span></b><span style="color: #ff0000">()</span><span style="color: #ff0000">) &gt;</span> intDaysOld and lcase<span style="color: #ff0000">(</span>right<span style="color: #ff0000">(</span>ObjLogFile<span style="color: #ff0000">,</span><b><span style="color: #008080">4</span></b><span style="color: #ff0000">))</span><span style="color: #ff0000">=</span>strLogFIleSuffix then<br /><img alt="" src="/img/sc/clear.gif" align="top" />                    <span style="color: #008000">'*****************************************************</span><br /><img alt="" src="/img/sc/clear.gif" align="top" />                    <span style="color: #008000">'DON'T UNCOMMENT THIS UNTIL YOU KNOW IT WORKS PROPERLY!!!</span><br /><img alt="" src="/img/sc/clear.gif" align="top" />                    WScript<span style="color: #ff0000">.</span><span style="color: #ff0000">Echo(</span><span style="color: #4682b4">"    Will</span> <span style="color: #4682b4">delete "</span> &amp; ObjSubFolder<span style="color: #ff0000">.</span>name &amp; <span style="color: #4682b4">"</span><span style="color: #4682b4">\"</span> &amp; ObjFile<span style="color: #ff0000">.</span>name<span style="color: #ff0000">)</span><br /><img alt="" src="/img/sc/clear.gif" align="top" />                    <span style="color: #008000">'WScript.Echo("    Deleted " &amp; ObjSubFolder.name &amp; "\" &amp; ObjFile.name)</span><br /><img alt="" src="/img/sc/clear.gif" align="top" />                    <span style="color: #008000">'ObjFile.Delete</span><br /><img alt="" src="/img/sc/clear.gif" align="top" />                    <span style="color: #008000">'*****************************************************</span><br /><img alt="" src="/img/sc/clear.gif" align="top" />                <b><span style="color: #0000ff">End</span></b> <b><span style="color: #0000ff">If</span></b><br /><img alt="" src="/img/sc/clear.gif" align="top" />                <b><span style="color: #0000ff">Set</span></b> ObjFile <span style="color: #ff0000">=</span> nothing<br /><img alt="" src="/img/sc/clear.gif" align="top" />            <b><span style="color: #0000ff">Next</span></b><br /><img alt="" src="/img/sc/clear.gif" align="top" />        <b><span style="color: #0000ff">Set</span></b> ObjSubFolder <span style="color: #ff0000">=</span> nothing<br /><img alt="" src="/img/sc/clear.gif" align="top" />    <b><span style="color: #0000ff">Next</span></b><br /><img alt="" src="/img/sc/clear.gif" align="top" /><b><span style="color: #0000ff">Next</span></b><br /><img alt="" src="/img/sc/clear.gif" align="top" /><br /><img alt="" src="/img/sc/clear.gif" align="top" /><b><span style="color: #0000ff">Set</span></b> ObjTopFolder <span style="color: #ff0000">=</span> nothing<br /><img alt="" src="/img/sc/clear.gif" align="top" /><b><span style="color: #0000ff">Set</span></b> ObjFS <span style="color: #ff0000">=</span> nothing<br /></div>
        <img width="0" height="0" src="http://blogs.thesitedoctor.co.uk/tim/aggbug.ashx?id=9d04c0af-248a-487e-b8d7-0b4bc8b8f6a1" />
      </body>
      <title>Automatically delete old IIS log files</title>
      <guid isPermaLink="false">http://blogs.thesitedoctor.co.uk/tim/PermaLink,guid,9d04c0af-248a-487e-b8d7-0b4bc8b8f6a1.aspx</guid>
      <link>http://blogs.thesitedoctor.co.uk/tim/2007/02/10/Automatically+Delete+Old+IIS+Log+Files.aspx</link>
      <pubDate>Sat, 10 Feb 2007 16:23:10 GMT</pubDate>
      <description>&lt;p&gt;
This is a really useful little VBS script that I’ve been meaning to post for a while
now (along with a couple of other little applications I’ve written for log file analysis).
I don’t think I wrote this script but at the same time can’t recall where it came
from.
&lt;/p&gt;
&lt;p&gt;
It basically traverses the 
&lt;abbr title="Filesystem Object"&gt;
FSO
&lt;/abbr&gt;
finding files with the designated extension and assuming the match the standard IIS
date format, checks whether they’re older than x days, if they are deletes them. Running
it is simple, place somewhere obvious on the server and just double click it. Alternatively
if you want to read the output, run it from CMD. For safety’s sake, the first time
you run it I would leave it just printing out the files that will be deleted.
&lt;/p&gt;
&lt;p&gt;
Personally I don’t schedule this script as although automation is great, I’ll probably
have it delete the logs before I’ve had a chance to download them so what I tend to
do is download the logs and then after that (or the next time I’m on 
&lt;abbr title="Remote Desktop Connection"&gt;
RDC
&lt;/abbr&gt;
) I run it, I find that way I ensure I get all the log files i.e. if I go on holiday.
&lt;/p&gt;
&lt;p&gt;
I’ve got two other applications that I’ll post shortly, one outputs the location of
the log files for each domain name within IIS and the other combines the log files
into one for analysis –it also takes the exported file/folder locations and names
the combined log files with the domain’s name –saves a ton of time!
&lt;/p&gt;
&lt;p&gt;
&lt;a title="Download the ZIP file containing the VBS script" href="/tim/files/deletelogfiles.zip"&gt;Download
the VBS script as a ZIP file&lt;/a&gt;
&lt;/p&gt;
&lt;div class="code"&gt;&lt;img alt="" src="/img/sc/clear.gif" align="top"&gt;&lt;b&gt;&lt;span style="color: #0000ff"&gt;Option&lt;/span&gt;&lt;/b&gt;&amp;nbsp;&lt;b&gt;&lt;span style="color: #0000ff"&gt;Explicit&lt;/span&gt;&lt;/b&gt;
&lt;br&gt;
&lt;img alt="" src="/img/sc/clear.gif" align="top"&gt;
&lt;br&gt;
&lt;img alt="" src="/img/sc/clear.gif" align="top"&gt;&lt;b&gt;&lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt;&lt;/b&gt;&amp;nbsp;intDaysOld&lt;span style="color: #ff0000"&gt;,&lt;/span&gt;&amp;nbsp;strObjTopFolderPath&lt;span style="color: #ff0000"&gt;,&lt;/span&gt;&amp;nbsp;strLogFIleSuffix&lt;span style="color: #ff0000"&gt;,&lt;/span&gt;&amp;nbsp;ObjFS&lt;span style="color: #ff0000"&gt;,&lt;/span&gt;&amp;nbsp;ObjTopFolder&amp;nbsp;&lt;br&gt;
&lt;img alt="" src="/img/sc/clear.gif" align="top"&gt;&lt;b&gt;&lt;span style="color: #0000ff"&gt;Dim&lt;/span&gt;&lt;/b&gt;&amp;nbsp;ObjDomainFolder&lt;span style="color: #ff0000"&gt;,&lt;/span&gt;&amp;nbsp;ObjW3SvcFolder&lt;span style="color: #ff0000"&gt;,&lt;/span&gt;&amp;nbsp;ObjSubFolder&lt;span style="color: #ff0000"&gt;,&lt;/span&gt;&amp;nbsp;ObjLogFile&lt;span style="color: #ff0000"&gt;,&lt;/span&gt;&amp;nbsp;ObjFile&lt;br&gt;
&lt;img alt="" src="/img/sc/clear.gif" align="top"&gt;
&lt;br&gt;
&lt;img alt="" src="/img/sc/clear.gif" align="top"&gt;intDaysOld&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: #ff0000"&gt;=&lt;/span&gt;&amp;nbsp;&lt;b&gt;&lt;span style="color: #008080"&gt;5&lt;/span&gt;&lt;/b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: #008000"&gt;'&lt;/span&gt;&lt;span style="color: #008000"&gt;Number&lt;/span&gt;&amp;nbsp;&lt;span style="color: #008000"&gt;of&amp;nbsp;days&amp;nbsp;to&amp;nbsp;retain&amp;nbsp;on&amp;nbsp;the&amp;nbsp;server&lt;/span&gt;
&lt;br&gt;
&lt;img alt="" src="/img/sc/clear.gif" align="top"&gt;strObjTopFolderPath&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: #ff0000"&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style="color: #4682b4"&gt;""&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: #008000"&gt;'The&lt;/span&gt;&amp;nbsp;&lt;span style="color: #008000"&gt;location&amp;nbsp;of&amp;nbsp;your&amp;nbsp;log&amp;nbsp;files&lt;/span&gt;
&lt;br&gt;
&lt;img alt="" src="/img/sc/clear.gif" align="top"&gt;strLogFIleSuffix&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: #ff0000"&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style="color: #4682b4"&gt;".log"&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: #008000"&gt;'The&amp;nbsp;suffix&lt;/span&gt;&amp;nbsp;&lt;span style="color: #008000"&gt;of&amp;nbsp;your&amp;nbsp;log&amp;nbsp;files&lt;/span&gt;
&lt;br&gt;
&lt;img alt="" src="/img/sc/clear.gif" align="top"&gt;
&lt;br&gt;
&lt;img alt="" src="/img/sc/clear.gif" align="top"&gt;&lt;b&gt;&lt;span style="color: #0000ff"&gt;Set&lt;/span&gt;&lt;/b&gt;&amp;nbsp;ObjFS&amp;nbsp;&lt;span style="color: #ff0000"&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style="color: #ff0000"&gt;CreateObject(&lt;/span&gt;&lt;span style="color: #4682b4"&gt;"Scripting.FileSystemObject&lt;/span&gt;&lt;span style="color: #4682b4"&gt;"&lt;/span&gt;&lt;span style="color: #ff0000"&gt;)&lt;/span&gt;
&lt;br&gt;
&lt;img alt="" src="/img/sc/clear.gif" align="top"&gt;&lt;b&gt;&lt;span style="color: #0000ff"&gt;Set&lt;/span&gt;&lt;/b&gt;&amp;nbsp;ObjTopFolder&amp;nbsp;&lt;span style="color: #ff0000"&gt;=&lt;/span&gt;&amp;nbsp;ObjFS&lt;span style="color: #ff0000"&gt;.&lt;/span&gt;&lt;span style="color: #ff0000"&gt;GetFolder(&lt;/span&gt;strObjTopFolderPath&lt;span style="color: #ff0000"&gt;)&lt;/span&gt;
&lt;br&gt;
&lt;img alt="" src="/img/sc/clear.gif" align="top"&gt;
&lt;br&gt;
&lt;img alt="" src="/img/sc/clear.gif" align="top"&gt;&lt;b&gt;&lt;span style="color: #0000ff"&gt;For&lt;/span&gt;&lt;/b&gt;&amp;nbsp;&lt;b&gt;&lt;span style="color: #0000ff"&gt;Each&lt;/span&gt;&lt;/b&gt;&amp;nbsp;ObjDomainFolder&amp;nbsp;in&amp;nbsp;ObjTopFolder&lt;span style="color: #ff0000"&gt;.&lt;/span&gt;SubFolders&lt;br&gt;
&lt;img alt="" src="/img/sc/clear.gif" align="top"&gt;WScript&lt;span style="color: #ff0000"&gt;.&lt;/span&gt;&lt;span style="color: #ff0000"&gt;Echo(&lt;/span&gt;&lt;span style="color: #4682b4"&gt;"Folder:&lt;/span&gt;&amp;nbsp;&lt;span style="color: #4682b4"&gt;"&lt;/span&gt;&amp;nbsp;&amp;amp;&amp;nbsp;ObjDomainFolder&lt;span style="color: #ff0000"&gt;.&lt;/span&gt;name&lt;span style="color: #ff0000"&gt;)&lt;/span&gt;
&lt;br&gt;
&lt;img alt="" src="/img/sc/clear.gif" align="top"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;b&gt;&lt;span style="color: #0000ff"&gt;For&lt;/span&gt;&lt;/b&gt;&amp;nbsp;&lt;b&gt;&lt;span style="color: #0000ff"&gt;Each&lt;/span&gt;&lt;/b&gt;&amp;nbsp;ObjW3SvcFolder&amp;nbsp;in&amp;nbsp;ObjDomainFolder&lt;span style="color: #ff0000"&gt;.&lt;/span&gt;SubFolders&lt;br&gt;
&lt;img alt="" src="/img/sc/clear.gif" align="top"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;WScript&lt;span style="color: #ff0000"&gt;.&lt;/span&gt;&lt;span style="color: #ff0000"&gt;Echo(&lt;/span&gt;&lt;span style="color: #4682b4"&gt;"&amp;nbsp;&amp;nbsp;Folder:&lt;/span&gt;&amp;nbsp;&lt;span style="color: #4682b4"&gt;"&lt;/span&gt;&amp;nbsp;&amp;amp;&amp;nbsp;ObjW3SvcFolder&lt;span style="color: #ff0000"&gt;.&lt;/span&gt;name&lt;span style="color: #ff0000"&gt;)&lt;/span&gt;
&lt;br&gt;
&lt;img alt="" src="/img/sc/clear.gif" align="top"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;b&gt;&lt;span style="color: #0000ff"&gt;Set&lt;/span&gt;&lt;/b&gt;&amp;nbsp;ObjSubFolder&amp;nbsp;&lt;span style="color: #ff0000"&gt;=&lt;/span&gt;&amp;nbsp;ObjFS&lt;span style="color: #ff0000"&gt;.&lt;/span&gt;&lt;span style="color: #ff0000"&gt;GetFolder(&lt;/span&gt;ObjW3SvcFolder&lt;span style="color: #ff0000"&gt;)&lt;/span&gt;
&lt;br&gt;
&lt;img alt="" src="/img/sc/clear.gif" align="top"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;b&gt;&lt;span style="color: #0000ff"&gt;For&lt;/span&gt;&lt;/b&gt;&amp;nbsp;each&amp;nbsp;ObjLogFile&amp;nbsp;in&amp;nbsp;ObjSubFolder&lt;span style="color: #ff0000"&gt;.&lt;/span&gt;files&lt;br&gt;
&lt;img alt="" src="/img/sc/clear.gif" align="top"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;b&gt;&lt;span style="color: #0000ff"&gt;Set&lt;/span&gt;&lt;/b&gt;&amp;nbsp;ObjFile&amp;nbsp;&lt;span style="color: #ff0000"&gt;=&lt;/span&gt;&amp;nbsp;ObjFS&lt;span style="color: #ff0000"&gt;.&lt;/span&gt;&lt;span style="color: #ff0000"&gt;GetFile(&lt;/span&gt;ObjLogFile&lt;span style="color: #ff0000"&gt;)&lt;/span&gt;
&lt;br&gt;
&lt;img alt="" src="/img/sc/clear.gif" align="top"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;b&gt;&lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;/b&gt;&amp;nbsp;datediff&lt;span style="color: #ff0000"&gt;(&lt;/span&gt;&lt;span style="color: #4682b4"&gt;"d"&lt;/span&gt;&lt;span style="color: #ff0000"&gt;,&lt;/span&gt;ObjFile&lt;span style="color: #ff0000"&gt;.&lt;/span&gt;&lt;span style="color: #ff00ff"&gt;DateLastModified&lt;/span&gt;&lt;span style="color: #ff0000"&gt;,&lt;/span&gt;&lt;b&gt;&lt;span style="color: #00008b"&gt;Date&lt;/span&gt;&lt;/b&gt;&lt;span style="color: #ff0000"&gt;()&lt;/span&gt;&lt;span style="color: #ff0000"&gt;)&amp;nbsp;&amp;gt;&lt;/span&gt;&amp;nbsp;intDaysOld&amp;nbsp;and&amp;nbsp;lcase&lt;span style="color: #ff0000"&gt;(&lt;/span&gt;right&lt;span style="color: #ff0000"&gt;(&lt;/span&gt;ObjLogFile&lt;span style="color: #ff0000"&gt;,&lt;/span&gt;&lt;b&gt;&lt;span style="color: #008080"&gt;4&lt;/span&gt;&lt;/b&gt;&lt;span style="color: #ff0000"&gt;))&lt;/span&gt;&lt;span style="color: #ff0000"&gt;=&lt;/span&gt;strLogFIleSuffix&amp;nbsp;then&lt;br&gt;
&lt;img alt="" src="/img/sc/clear.gif" align="top"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: #008000"&gt;'*****************************************************&lt;/span&gt;
&lt;br&gt;
&lt;img alt="" src="/img/sc/clear.gif" align="top"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: #008000"&gt;'DON'T&amp;nbsp;UNCOMMENT&amp;nbsp;THIS&amp;nbsp;UNTIL&amp;nbsp;YOU&amp;nbsp;KNOW&amp;nbsp;IT&amp;nbsp;WORKS&amp;nbsp;PROPERLY!!!&lt;/span&gt;
&lt;br&gt;
&lt;img alt="" src="/img/sc/clear.gif" align="top"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;WScript&lt;span style="color: #ff0000"&gt;.&lt;/span&gt;&lt;span style="color: #ff0000"&gt;Echo(&lt;/span&gt;&lt;span style="color: #4682b4"&gt;"&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Will&lt;/span&gt;&amp;nbsp;&lt;span style="color: #4682b4"&gt;delete&amp;nbsp;"&lt;/span&gt;&amp;nbsp;&amp;amp;&amp;nbsp;ObjSubFolder&lt;span style="color: #ff0000"&gt;.&lt;/span&gt;name&amp;nbsp;&amp;amp;&amp;nbsp;&lt;span style="color: #4682b4"&gt;"&lt;/span&gt;&lt;span style="color: #4682b4"&gt;\"&lt;/span&gt;&amp;nbsp;&amp;amp;&amp;nbsp;ObjFile&lt;span style="color: #ff0000"&gt;.&lt;/span&gt;name&lt;span style="color: #ff0000"&gt;)&lt;/span&gt;
&lt;br&gt;
&lt;img alt="" src="/img/sc/clear.gif" align="top"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: #008000"&gt;'WScript.Echo("&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Deleted&amp;nbsp;"&amp;nbsp;&amp;amp;&amp;nbsp;ObjSubFolder.name&amp;nbsp;&amp;amp;&amp;nbsp;"\"&amp;nbsp;&amp;amp;&amp;nbsp;ObjFile.name)&lt;/span&gt;
&lt;br&gt;
&lt;img alt="" src="/img/sc/clear.gif" align="top"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: #008000"&gt;'ObjFile.Delete&lt;/span&gt;
&lt;br&gt;
&lt;img alt="" src="/img/sc/clear.gif" align="top"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: #008000"&gt;'*****************************************************&lt;/span&gt;
&lt;br&gt;
&lt;img alt="" src="/img/sc/clear.gif" align="top"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;b&gt;&lt;span style="color: #0000ff"&gt;End&lt;/span&gt;&lt;/b&gt;&amp;nbsp;&lt;b&gt;&lt;span style="color: #0000ff"&gt;If&lt;/span&gt;&lt;/b&gt;
&lt;br&gt;
&lt;img alt="" src="/img/sc/clear.gif" align="top"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;b&gt;&lt;span style="color: #0000ff"&gt;Set&lt;/span&gt;&lt;/b&gt;&amp;nbsp;ObjFile&amp;nbsp;&lt;span style="color: #ff0000"&gt;=&lt;/span&gt;&amp;nbsp;nothing&lt;br&gt;
&lt;img alt="" src="/img/sc/clear.gif" align="top"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;b&gt;&lt;span style="color: #0000ff"&gt;Next&lt;/span&gt;&lt;/b&gt;
&lt;br&gt;
&lt;img alt="" src="/img/sc/clear.gif" align="top"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;b&gt;&lt;span style="color: #0000ff"&gt;Set&lt;/span&gt;&lt;/b&gt;&amp;nbsp;ObjSubFolder&amp;nbsp;&lt;span style="color: #ff0000"&gt;=&lt;/span&gt;&amp;nbsp;nothing&lt;br&gt;
&lt;img alt="" src="/img/sc/clear.gif" align="top"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;b&gt;&lt;span style="color: #0000ff"&gt;Next&lt;/span&gt;&lt;/b&gt;
&lt;br&gt;
&lt;img alt="" src="/img/sc/clear.gif" align="top"&gt;&lt;b&gt;&lt;span style="color: #0000ff"&gt;Next&lt;/span&gt;&lt;/b&gt;
&lt;br&gt;
&lt;img alt="" src="/img/sc/clear.gif" align="top"&gt;
&lt;br&gt;
&lt;img alt="" src="/img/sc/clear.gif" align="top"&gt;&lt;b&gt;&lt;span style="color: #0000ff"&gt;Set&lt;/span&gt;&lt;/b&gt;&amp;nbsp;ObjTopFolder&amp;nbsp;&lt;span style="color: #ff0000"&gt;=&lt;/span&gt;&amp;nbsp;nothing&lt;br&gt;
&lt;img alt="" src="/img/sc/clear.gif" align="top"&gt;&lt;b&gt;&lt;span style="color: #0000ff"&gt;Set&lt;/span&gt;&lt;/b&gt;&amp;nbsp;ObjFS&amp;nbsp;&lt;span style="color: #ff0000"&gt;=&lt;/span&gt;&amp;nbsp;nothing&lt;br&gt;
&lt;/div&gt;
&lt;img width="0" height="0" src="http://blogs.thesitedoctor.co.uk/tim/aggbug.ashx?id=9d04c0af-248a-487e-b8d7-0b4bc8b8f6a1" /&gt;</description>
      <comments>http://blogs.thesitedoctor.co.uk/tim/CommentView,guid,9d04c0af-248a-487e-b8d7-0b4bc8b8f6a1.aspx</comments>
      <category>IIS</category>
      <category>Software/Windows</category>
    </item>
    <item>
      <trackback:ping>http://blogs.thesitedoctor.co.uk/tim/Trackback.aspx?guid=3ddcd5e5-0fb8-4ec9-9486-cbad6a622ead</trackback:ping>
      <pingback:server>http://blogs.thesitedoctor.co.uk/tim/pingback.aspx</pingback:server>
      <pingback:target>http://blogs.thesitedoctor.co.uk/tim/PermaLink,guid,3ddcd5e5-0fb8-4ec9-9486-cbad6a622ead.aspx</pingback:target>
      <dc:creator>Tim</dc:creator>
      <wfw:comment>http://blogs.thesitedoctor.co.uk/tim/CommentView,guid,3ddcd5e5-0fb8-4ec9-9486-cbad6a622ead.aspx</wfw:comment>
      <wfw:commentRss>http://blogs.thesitedoctor.co.uk/tim/SyndicationService.asmx/GetEntryCommentsRss?guid=3ddcd5e5-0fb8-4ec9-9486-cbad6a622ead</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
This is a useful Regex that Craig wrote today, it pulls out various info from an apache
log file.<br /></p>
        <div class="code">
          <img src="/img/sc/clear.gif" align="top" />
          <b>
            <span style="color: rgb(0, 0, 255);">private</span>
          </b> <b><span style="color: rgb(0, 0, 255);">static</span></b> Regex __Regex <span style="color: rgb(255, 0, 0);">=</span> <b><span style="color: rgb(0, 0, 255);">null</span></b>;  <br /><img src="/img/sc/clear.gif" align="top" /><b><span style="color: rgb(0, 0, 255);">internal</span></b> <b><span style="color: rgb(0, 0, 255);">static</span></b> Regex _Regex  <br /><div style="display: none;" id="closed632979973631406250_3"><img src="/img/sc/PlusNoLines.gif" onclick="open632979973631406250_3.style.display='block'; closed632979973631406250_3.style.display='none'; " align="top" /><b><span style="color: rgb(0, 0, 139); background-color: rgb(192, 192, 192);">{...}</span></b></div><div style="display: block;" id="open632979973631406250_3"><img src="/img/sc/minusNoTopLine.gif" onclick="open632979973631406250_3.style.display='none'; closed632979973631406250_3.style.display='block'; " align="top" />{  <br /><img src="/img/sc/I.gif" align="top" />    <b><span style="color: rgb(0, 0, 255);">get</span></b>  <br /><div style="display: none;" id="closed632979973631406250_5"><img src="/img/sc/plus.gif" onclick="open632979973631406250_5.style.display='block'; closed632979973631406250_5.style.display='none';" align="top" />    <b><span style="color: rgb(0, 0, 139); background-color: rgb(192, 192, 192);">{...}</span></b>  
</div><div style="display: block;" id="open632979973631406250_5"><img src="/img/sc/minus.gif" onclick="open632979973631406250_5.style.display='none'; closed632979973631406250_5.style.display='block'; " align="top" />    {  <br /><img src="/img/sc/I.gif" align="top" />        <b><span style="color: rgb(0, 0, 255);">if</span></b> (__Regex <span style="color: rgb(255, 0, 0);">=</span><span style="color: rgb(255, 0, 0);">=</span> <b><span style="color: rgb(0, 0, 255);">null</span></b>)  <br /><div style="display: none;" id="closed632979973631406250_7"><img src="/img/sc/plus.gif" onclick="open632979973631406250_7.style.display='block'; closed632979973631406250_7.style.display='none'; " align="top" />        <b><span style="color: rgb(0, 0, 139); background-color: rgb(192, 192, 192);">{...}</span></b>  
</div><div style="display: block;" id="open632979973631406250_7"><img src="/img/sc/minus.gif" onclick="open632979973631406250_7.style.display='none'; closed632979973631406250_7.style.display='block'; " align="top" />        {  <br /><img src="/img/sc/I.gif" align="top" />            __Regex <span style="color: rgb(255, 0, 0);">=</span> <b><span style="color: rgb(0, 0, 255);">new</span></b> Regex(<span style="color: rgb(70, 130, 180);">@"(?&lt;remoteHost&gt;[^\ ]+?)\ (?&lt;remoteIdent&gt;[^\ ]+?)\ (?&lt;remoteUs"</span><br /><img src="/img/sc/I.gif" align="top" />                <span style="color: rgb(255, 0, 0);">+</span> <span style="color: rgb(70, 130, 180);">@"er&gt;[^\ ]+?)\ \[(?&lt;requestTime&gt;[^\]]+?)\]\ \""(?&lt;request&gt;(?&lt;r"</span>  <br /><img src="/img/sc/I.gif" align="top" />                <span style="color: rgb(255, 0, 0);">+</span> <span style="color: rgb(70, 130, 180);">@"equestMethod&gt;[^\ ]+?)?\ ?(?&lt;requestPath&gt;[^\ ]+?)?\ ?(?&lt;reque"</span><br /><img src="/img/sc/I.gif" align="top" />                <span style="color: rgb(255, 0, 0);">+</span> <span style="color: rgb(70, 130, 180);">@"stProtocol&gt;[^\ ]+?)?)\""\ (?&lt;statusCode&gt;[^\ ]+?)\ (?&lt;sizeByt"</span><br /><img src="/img/sc/I.gif" align="top" />                <span style="color: rgb(255, 0, 0);">+</span> <span style="color: rgb(70, 130, 180);">@"es&gt;[^\ ]+?)\ \""(?&lt;referer&gt;[^\""]*?)\""\ \""(?&lt;userAgent&gt;[^\""]"</span><br /><img src="/img/sc/I.gif" align="top" />                <span style="color: rgb(255, 0, 0);">+</span> <span style="color: rgb(70, 130, 180);">@"+?)\""\r?\n?"</span>, <br /><img src="/img/sc/I.gif" align="top" />                RegexOptions<span style="color: rgb(255, 0, 0);">.</span>Compiled &amp; RegexOptions<span style="color: rgb(255, 0, 0);">.</span>IgnoreCase &amp; RegexOptions<span style="color: rgb(255, 0, 0);">.</span>IgnorePatternWhitespace &amp; RegexOptions<span style="color: rgb(255, 0, 0);">.</span>CultureInvariant);<br /><img src="/img/sc/L.gif" align="top" />        }  
</div><img src="/img/sc/I.gif" align="top" />        <b><span style="color: rgb(0, 0, 255);">return</span></b> __Regex;  <br /><img src="/img/sc/L.gif" align="top" />    }  
</div><img src="/img/sc/L.gif" align="top" />}
</div></div>
        <p>
          <b>Update:</b> Craig's finally started writing about it, you can read the article
here: <a href="http://blogs.thesitedoctor.co.uk/craig/PermaLink,guid,53c2f522-4f2e-49d9-8bee-0c3abc3d5b68.aspx">Apache
Log Fun</a></p>
        <img width="0" height="0" src="http://blogs.thesitedoctor.co.uk/tim/aggbug.ashx?id=3ddcd5e5-0fb8-4ec9-9486-cbad6a622ead" />
      </body>
      <title>Parsing Apache Log files</title>
      <guid isPermaLink="false">http://blogs.thesitedoctor.co.uk/tim/PermaLink,guid,3ddcd5e5-0fb8-4ec9-9486-cbad6a622ead.aspx</guid>
      <link>http://blogs.thesitedoctor.co.uk/tim/2006/11/01/Parsing+Apache+Log+Files.aspx</link>
      <pubDate>Wed, 01 Nov 2006 17:21:16 GMT</pubDate>
      <description>&lt;p&gt;
This is a useful Regex that Craig wrote today, it pulls out various info from an apache
log file.&lt;br&gt;
&lt;/p&gt;
&lt;div class="code"&gt;
&lt;img src="/img/sc/clear.gif" align="top"&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;private&lt;/span&gt;&lt;/b&gt;&amp;nbsp;&lt;b&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;static&lt;/span&gt;&lt;/b&gt;&amp;nbsp;Regex&amp;nbsp;__Regex&amp;nbsp;&lt;span style="color: rgb(255, 0, 0);"&gt;=&lt;/span&gt;&amp;nbsp;&lt;b&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;null&lt;/span&gt;&lt;/b&gt;;&amp;nbsp;&amp;nbsp;&lt;br&gt;
&lt;img src="/img/sc/clear.gif" align="top"&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;internal&lt;/span&gt;&lt;/b&gt;&amp;nbsp;&lt;b&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;static&lt;/span&gt;&lt;/b&gt;&amp;nbsp;Regex&amp;nbsp;_Regex&amp;nbsp;&amp;nbsp;&lt;br&gt;
&lt;div style="display: none;" id="closed632979973631406250_3"&gt;&lt;img src="/img/sc/PlusNoLines.gif" onclick="open632979973631406250_3.style.display='block'; closed632979973631406250_3.style.display='none'; " align="top"&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 139); background-color: rgb(192, 192, 192);"&gt;{...}&lt;/span&gt;&lt;/b&gt;
&lt;/div&gt;
&lt;div style="display: block;" id="open632979973631406250_3"&gt;&lt;img src="/img/sc/minusNoTopLine.gif" onclick="open632979973631406250_3.style.display='none'; closed632979973631406250_3.style.display='block'; " align="top"&gt;{&amp;nbsp;&amp;nbsp;&lt;br&gt;
&lt;img src="/img/sc/I.gif" align="top"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;b&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;get&lt;/span&gt;&lt;/b&gt;&amp;nbsp;&amp;nbsp;&lt;br&gt;
&lt;div style="display: none;" id="closed632979973631406250_5"&gt;&lt;img src="/img/sc/plus.gif" onclick="open632979973631406250_5.style.display='block'; closed632979973631406250_5.style.display='none';" align="top"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;b&gt;&lt;span style="color: rgb(0, 0, 139); background-color: rgb(192, 192, 192);"&gt;{...}&lt;/span&gt;&lt;/b&gt;&amp;nbsp;&amp;nbsp;
&lt;/div&gt;
&lt;div style="display: block;" id="open632979973631406250_5"&gt;&lt;img src="/img/sc/minus.gif" onclick="open632979973631406250_5.style.display='none'; closed632979973631406250_5.style.display='block'; " align="top"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&amp;nbsp;&amp;nbsp;&lt;br&gt;
&lt;img src="/img/sc/I.gif" align="top"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;b&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt;&lt;/b&gt;&amp;nbsp;(__Regex&amp;nbsp;&lt;span style="color: rgb(255, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;=&lt;/span&gt;&amp;nbsp;&lt;b&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;null&lt;/span&gt;&lt;/b&gt;)&amp;nbsp;&amp;nbsp;&lt;br&gt;
&lt;div style="display: none;" id="closed632979973631406250_7"&gt;&lt;img src="/img/sc/plus.gif" onclick="open632979973631406250_7.style.display='block'; closed632979973631406250_7.style.display='none'; " align="top"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;b&gt;&lt;span style="color: rgb(0, 0, 139); background-color: rgb(192, 192, 192);"&gt;{...}&lt;/span&gt;&lt;/b&gt;&amp;nbsp;&amp;nbsp;
&lt;/div&gt;
&lt;div style="display: block;" id="open632979973631406250_7"&gt;&lt;img src="/img/sc/minus.gif" onclick="open632979973631406250_7.style.display='none'; closed632979973631406250_7.style.display='block'; " align="top"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&amp;nbsp;&amp;nbsp;&lt;br&gt;
&lt;img src="/img/sc/I.gif" align="top"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;__Regex&amp;nbsp;&lt;span style="color: rgb(255, 0, 0);"&gt;=&lt;/span&gt;&amp;nbsp;&lt;b&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt;&lt;/b&gt;&amp;nbsp;Regex(&lt;span style="color: rgb(70, 130, 180);"&gt;@"(?&amp;lt;remoteHost&amp;gt;[^\&amp;nbsp;]+?)\&amp;nbsp;(?&amp;lt;remoteIdent&amp;gt;[^\&amp;nbsp;]+?)\&amp;nbsp;(?&amp;lt;remoteUs"&lt;/span&gt;
&lt;br&gt;
&lt;img src="/img/sc/I.gif" align="top"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(255, 0, 0);"&gt;+&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(70, 130, 180);"&gt;@"er&amp;gt;[^\&amp;nbsp;]+?)\&amp;nbsp;\[(?&amp;lt;requestTime&amp;gt;[^\]]+?)\]\&amp;nbsp;\""(?&amp;lt;request&amp;gt;(?&amp;lt;r"&lt;/span&gt;&amp;nbsp;&amp;nbsp;&lt;br&gt;
&lt;img src="/img/sc/I.gif" align="top"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(255, 0, 0);"&gt;+&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(70, 130, 180);"&gt;@"equestMethod&amp;gt;[^\&amp;nbsp;]+?)?\&amp;nbsp;?(?&amp;lt;requestPath&amp;gt;[^\&amp;nbsp;]+?)?\&amp;nbsp;?(?&amp;lt;reque"&lt;/span&gt;
&lt;br&gt;
&lt;img src="/img/sc/I.gif" align="top"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(255, 0, 0);"&gt;+&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(70, 130, 180);"&gt;@"stProtocol&amp;gt;[^\&amp;nbsp;]+?)?)\""\&amp;nbsp;(?&amp;lt;statusCode&amp;gt;[^\&amp;nbsp;]+?)\&amp;nbsp;(?&amp;lt;sizeByt"&lt;/span&gt;
&lt;br&gt;
&lt;img src="/img/sc/I.gif" align="top"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(255, 0, 0);"&gt;+&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(70, 130, 180);"&gt;@"es&amp;gt;[^\&amp;nbsp;]+?)\&amp;nbsp;\""(?&amp;lt;referer&amp;gt;[^\""]*?)\""\&amp;nbsp;\""(?&amp;lt;userAgent&amp;gt;[^\""]"&lt;/span&gt;
&lt;br&gt;
&lt;img src="/img/sc/I.gif" align="top"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: rgb(255, 0, 0);"&gt;+&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(70, 130, 180);"&gt;@"+?)\""\r?\n?"&lt;/span&gt;,&amp;nbsp;&lt;br&gt;
&lt;img src="/img/sc/I.gif" align="top"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;RegexOptions&lt;span style="color: rgb(255, 0, 0);"&gt;.&lt;/span&gt;Compiled&amp;nbsp;&amp;amp;&amp;nbsp;RegexOptions&lt;span style="color: rgb(255, 0, 0);"&gt;.&lt;/span&gt;IgnoreCase&amp;nbsp;&amp;amp;&amp;nbsp;RegexOptions&lt;span style="color: rgb(255, 0, 0);"&gt;.&lt;/span&gt;IgnorePatternWhitespace&amp;nbsp;&amp;amp;&amp;nbsp;RegexOptions&lt;span style="color: rgb(255, 0, 0);"&gt;.&lt;/span&gt;CultureInvariant);&lt;br&gt;
&lt;img src="/img/sc/L.gif" align="top"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&amp;nbsp;&amp;nbsp;
&lt;/div&gt;
&lt;img src="/img/sc/I.gif" align="top"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;b&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt;&lt;/b&gt;&amp;nbsp;__Regex;&amp;nbsp;&amp;nbsp;&lt;br&gt;
&lt;img src="/img/sc/L.gif" align="top"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&amp;nbsp;&amp;nbsp;
&lt;/div&gt;
&lt;img src="/img/sc/L.gif" align="top"&gt;}
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;b&gt;Update:&lt;/b&gt; Craig's finally started writing about it, you can read the article
here: &lt;a href="http://blogs.thesitedoctor.co.uk/craig/PermaLink,guid,53c2f522-4f2e-49d9-8bee-0c3abc3d5b68.aspx"&gt;Apache
Log Fun&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blogs.thesitedoctor.co.uk/tim/aggbug.ashx?id=3ddcd5e5-0fb8-4ec9-9486-cbad6a622ead" /&gt;</description>
      <comments>http://blogs.thesitedoctor.co.uk/tim/CommentView,guid,3ddcd5e5-0fb8-4ec9-9486-cbad6a622ead.aspx</comments>
      <category>ASP.Net</category>
      <category>IIS</category>
    </item>
    <item>
      <trackback:ping>http://blogs.thesitedoctor.co.uk/tim/Trackback.aspx?guid=00cefff0-f235-4cf2-9c0f-009731aebc1c</trackback:ping>
      <pingback:server>http://blogs.thesitedoctor.co.uk/tim/pingback.aspx</pingback:server>
      <pingback:target>http://blogs.thesitedoctor.co.uk/tim/PermaLink,guid,00cefff0-f235-4cf2-9c0f-009731aebc1c.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://blogs.thesitedoctor.co.uk/tim/CommentView,guid,00cefff0-f235-4cf2-9c0f-009731aebc1c.aspx</wfw:comment>
      <wfw:commentRss>http://blogs.thesitedoctor.co.uk/tim/SyndicationService.asmx/GetEntryCommentsRss?guid=00cefff0-f235-4cf2-9c0f-009731aebc1c</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I made an interesting discovery this morning. A few weeks ago I was doing a little
SEO on <a href="http://www.wargamecompany.co.uk/">The Wargame Company (Devon)</a> and
thought I would look into utilising <a href="http://www.google.com/webmasters/sitemaps/">Google
SiteMaps</a>. After creating the XML file with the correct format it's just a matter
of having Google approve it. They do this by accessing a random page i.e. <u><a href="http://www.domain.com/GooglesWonderfulPageddmmyyyyhhmmssmmm">www.domain.com/GooglesWonderfulPageddmmyyyyhhmmssmmm</a></u> (which
clearly should return a 404) and check the response code -I guess to ensure that you're
not trying to spoof the pages in some way.
</p>
        <p>
"What's the problem? I've got custom 404 pages" I hear you cry! Well, if like
us you've written some fancy page to handle the error and email you/log it to a database, it
turns out that you're not returning a 404 error at all!
</p>
        <p>
What I discovered was that if you configure IIS to handle 404 error pages with a URL
you're actually returning a response code of 200. After a little thinking, the only
conclusion we could come to was that when setting it as a URL in IIS you're actually
redirecting the request which is either a 301 or perhaps a 307 (see <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html">http://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html</a> for
more information on response codes) and then the final page the user hit's returns
a 200 (Response Status "OK") rather than the desired 404 -clearly not what we want!
</p>
        <p>
After a little more investigation we also found that the same thing happened when
using ASP.Net's built in handlers and the same thing happens, the only time it doesn't
is when you handle the 404 with a File in IIS rather than a URL.
</p>
        <p>
"What can I do about it?" Well that's simple, if you're going to use a URL to handle
your 404 errors, make sure you change the Response Status Codes to the correct code,
i.e. 404, this is pretty simple to do:
</p>
        <p>
          <strong>ASP.Net 2.0:</strong>
          <span style="font-size: 11px; color: black; font-family: Courier New; background-color: transparent;">Page.Response.StatusCode <span style="color: red;">=</span> 404;</span>
        </p>
        <p>
          <strong>ASP.Net 1.1 (I think):</strong>
          <span style="font-size: 11px; color: black; font-family: Courier New; background-color: transparent;">Response.StatusCode <span style="color: red;">=</span> 404;</span>
        </p>
        <p>
          <strong>ASP:</strong>
          <span style="font-size: 11px; color: black; font-family: Courier New; background-color: transparent;">Response.Status <span style="color: red;">=</span><span style="color: green;">"404
You are Unauthorized"</span></span>
        </p>
        <p>
I hope that helps someone out there!
</p>
        <p>
Tim
</p>
        <p>
          <strong>Update:</strong> I've just run fiddler on <a href="http://www.wargamecompany.co.uk/">The
Wargame Company (Devon)</a> and and can confirm you get a Response Status Code
of 301 before the 200.
</p>
        <img width="0" height="0" src="http://blogs.thesitedoctor.co.uk/tim/aggbug.ashx?id=00cefff0-f235-4cf2-9c0f-009731aebc1c" />
      </body>
      <title>Custom 404 Error Pages</title>
      <guid isPermaLink="false">http://blogs.thesitedoctor.co.uk/tim/PermaLink,guid,00cefff0-f235-4cf2-9c0f-009731aebc1c.aspx</guid>
      <link>http://blogs.thesitedoctor.co.uk/tim/2006/06/16/Custom+404+Error+Pages.aspx</link>
      <pubDate>Fri, 16 Jun 2006 20:48:54 GMT</pubDate>
      <description>&lt;p&gt;
I made an interesting discovery this morning. A few weeks ago I was doing a little
SEO on &lt;a href="http://www.wargamecompany.co.uk/"&gt;The Wargame Company (Devon)&lt;/a&gt;&amp;nbsp;and
thought I would look into utilising &lt;a href="http://www.google.com/webmasters/sitemaps/"&gt;Google
SiteMaps&lt;/a&gt;. After creating the XML file with the correct format it's just a matter
of having Google approve it. They do this by&amp;nbsp;accessing a random page i.e. &lt;u&gt;&lt;a href="http://www.domain.com/GooglesWonderfulPageddmmyyyyhhmmssmmm"&gt;www.domain.com/GooglesWonderfulPageddmmyyyyhhmmssmmm&lt;/a&gt;&lt;/u&gt; (which
clearly should return a 404) and check the response code -I guess to ensure that you're
not trying to spoof the pages in some way.
&lt;/p&gt;
&lt;p&gt;
"What's the problem? I've got custom 404 pages"&amp;nbsp;I hear you cry! Well, if like
us you've written some fancy page to handle the error and email you/log it to a database,&amp;nbsp;it
turns out that you're not returning a 404 error at all!
&lt;/p&gt;
&lt;p&gt;
What I discovered was that if you configure IIS to handle 404 error pages with a URL
you're actually returning a response code of 200. After a little thinking, the only
conclusion we could come to was that when setting it as a URL in IIS you're actually
redirecting the request which is either a 301 or perhaps a 307 (see &lt;a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html"&gt;http://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html&lt;/a&gt;&amp;nbsp;for
more information on response codes) and then the final page the user hit's returns
a 200 (Response Status "OK") rather than the desired 404 -clearly not what we want!
&lt;/p&gt;
&lt;p&gt;
After a little more investigation we also found that the same thing happened when
using ASP.Net's built in handlers and the same thing happens, the only time it doesn't
is when you handle the 404 with a File in IIS rather than a URL.
&lt;/p&gt;
&lt;p&gt;
"What can I do about it?" Well that's simple, if you're going to use a URL to handle
your 404 errors, make sure you change the Response Status Codes to the correct code,
i.e. 404, this is pretty simple to do:
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;ASP.Net 2.0:&lt;/strong&gt; &lt;span style="font-size: 11px; color: black; font-family: Courier New; background-color: transparent;"&gt;Page.Response.StatusCode &lt;span style="color: red;"&gt;=&lt;/span&gt; 404;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;ASP.Net 1.1 (I think):&lt;/strong&gt; &lt;span style="font-size: 11px; color: black; font-family: Courier New; background-color: transparent;"&gt;Response.StatusCode &lt;span style="color: red;"&gt;=&lt;/span&gt; 404;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;ASP:&lt;/strong&gt; &lt;span style="font-size: 11px; color: black; font-family: Courier New; background-color: transparent;"&gt;Response.Status &lt;span style="color: red;"&gt;=&lt;/span&gt; &lt;span style="color: green;"&gt;"404
You are Unauthorized"&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
I hope that helps someone out there!
&lt;/p&gt;
&lt;p&gt;
Tim
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Update:&lt;/strong&gt; I've just run fiddler on &lt;a href="http://www.wargamecompany.co.uk/"&gt;The
Wargame Company (Devon)&lt;/a&gt;&amp;nbsp;and and can confirm you get a Response Status Code
of 301 before the 200.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blogs.thesitedoctor.co.uk/tim/aggbug.ashx?id=00cefff0-f235-4cf2-9c0f-009731aebc1c" /&gt;</description>
      <comments>http://blogs.thesitedoctor.co.uk/tim/CommentView,guid,00cefff0-f235-4cf2-9c0f-009731aebc1c.aspx</comments>
      <category>ASP</category>
      <category>ASP.Net</category>
      <category>IIS</category>
      <category>SEO</category>
    </item>
  </channel>
</rss>