<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" 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:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>INauseous()</title>
        <link>http://geekswithblogs.net/cicorias/Default.aspx</link>
        <description>Shawn Cicoria - Solution Architect, Craftsman and Artisan - INauseous() - Main Blog Here: www.Cicoria.com</description>
        <language>en-US</language>
        <copyright>Shawn Cicoria</copyright>
        <managingEditor>shawn@cicoria.com</managingEditor>
        <generator>Subtext Version 0.0.0.0</generator>
        <image>
            <title>INauseous()</title>
            <url>http://geekswithblogs.net/images/RSS2Image.gif</url>
            <link>http://geekswithblogs.net/cicorias/Default.aspx</link>
            <width>77</width>
            <height>60</height>
        </image>
        <item>
            <title>Good use of the Charms Bar in Windows 8 Metro.</title>
            <link>http://geekswithblogs.net/cicorias/archive/2012/07/05/good-use-of-the-charms-bar-in-windows-8-metro.aspx</link>
            <description>&lt;p&gt;Originally posted on: &lt;a href='http://geekswithblogs.net/cicorias/archive/2012/07/05/good-use-of-the-charms-bar-in-windows-8-metro.aspx'&gt;http://geekswithblogs.net/cicorias/archive/2012/07/05/good-use-of-the-charms-bar-in-windows-8-metro.aspx&lt;/a&gt;&lt;/p&gt;&lt;p&gt;If you’re using Win8 yet, no doubt you’ve run into the charms bar.  There’s a feature to extend via Share, links to your application.&lt;/p&gt;  &lt;p&gt;Details on the HOW are here: &lt;/p&gt;  &lt;h3&gt;Adding share (Metro style apps using JavaScript and HTML)&lt;/h3&gt;  &lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh758314.aspx"&gt;http://msdn.microsoft.com/en-us/library/windows/apps/hh758314.aspx&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Do, Digital Folio has taken their shopping tool to Win8 and enabled some really cool ways to take advantage.  I was fortunate enough to help out the folks there a while back on some other things, but their app is a nice shoppers aid.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.digitalfolio.com/home/windows8"&gt;Digital Folio for Windows 8 | Instant Price Comparisons from Major Retailers on the Products You Want&lt;/a&gt;&lt;/p&gt; &lt;img src="http://geekswithblogs.net/cicorias/aggbug/150147.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Shawn Cicoria</dc:creator>
            <guid>http://geekswithblogs.net/cicorias/archive/2012/07/05/good-use-of-the-charms-bar-in-windows-8-metro.aspx</guid>
            <pubDate>Thu, 05 Jul 2012 18:23:51 GMT</pubDate>
            <comments>http://geekswithblogs.net/cicorias/archive/2012/07/05/good-use-of-the-charms-bar-in-windows-8-metro.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/cicorias/comments/commentRss/150147.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/cicorias/services/trackbacks/150147.aspx</trackback:ping>
        </item>
        <item>
            <title>Updated WIF tools for VS2012 RC are out&amp;ndash;be safe&amp;hellip;</title>
            <link>http://geekswithblogs.net/cicorias/archive/2012/06/20/updated-wif-tools-for-vs2012-rc-are-outndashbe-safehellip.aspx</link>
            <description>&lt;p&gt;Originally posted on: &lt;a href='http://geekswithblogs.net/cicorias/archive/2012/06/20/updated-wif-tools-for-vs2012-rc-are-outndashbe-safehellip.aspx'&gt;http://geekswithblogs.net/cicorias/archive/2012/06/20/updated-wif-tools-for-vs2012-rc-are-outndashbe-safehellip.aspx&lt;/a&gt;&lt;/p&gt;&lt;p&gt;The updated tools for the RC along with the samples are out.  The samples from the prior 1.0 release will still work as well &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/b/vbertocci/archive/2012/06/19/windows-identity-foundation-tools-for-visual-studio-2012-rc.aspx"&gt;Windows Identity Foundation Tools for Visual Studio 2012 RC - Vibro.NET - Site Home - MSDN Blogs&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Samples are at the bottom : &lt;a title="http://blogs.msdn.com/b/vbertocci/archive/2012/03/15/windows-identity-foundation-in-the-net-framework-4-5-beta-tools-samples-claims-everywhere.aspx" href="http://blogs.msdn.com/b/vbertocci/archive/2012/03/15/windows-identity-foundation-in-the-net-framework-4-5-beta-tools-samples-claims-everywhere.aspx"&gt;http://blogs.msdn.com/b/vbertocci/archive/2012/03/15/windows-identity-foundation-in-the-net-framework-4-5-beta-tools-samples-claims-everywhere.aspx&lt;/a&gt;&lt;/p&gt; &lt;img src="http://geekswithblogs.net/cicorias/aggbug/149994.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Shawn Cicoria</dc:creator>
            <guid>http://geekswithblogs.net/cicorias/archive/2012/06/20/updated-wif-tools-for-vs2012-rc-are-outndashbe-safehellip.aspx</guid>
            <pubDate>Wed, 20 Jun 2012 12:15:11 GMT</pubDate>
            <comments>http://geekswithblogs.net/cicorias/archive/2012/06/20/updated-wif-tools-for-vs2012-rc-are-outndashbe-safehellip.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/cicorias/comments/commentRss/149994.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/cicorias/services/trackbacks/149994.aspx</trackback:ping>
        </item>
        <item>
            <title>Turning off the Visual Studio &amp;ldquo;Attach to process&amp;rdquo; security warning&amp;hellip;</title>
            <link>http://geekswithblogs.net/cicorias/archive/2012/04/12/turning-off-the-visual-studio-ldquoattach-to-processrdquo-security-warninghellip.aspx</link>
            <description>&lt;p&gt;Originally posted on: &lt;a href='http://geekswithblogs.net/cicorias/archive/2012/04/12/turning-off-the-visual-studio-ldquoattach-to-processrdquo-security-warninghellip.aspx'&gt;http://geekswithblogs.net/cicorias/archive/2012/04/12/turning-off-the-visual-studio-ldquoattach-to-processrdquo-security-warninghellip.aspx&lt;/a&gt;&lt;/p&gt;&lt;p&gt;When you’re urnning under x64 you have to affect 1 addition spot in the registry to disable this warning – which clearly should only be done by folks that know what they’re doing.&lt;/p&gt;  &lt;p&gt;NOTE: affecting the registry can be harmful – do so at your own risk.&lt;/p&gt;  &lt;p&gt;Windows Registry Editor Version 5.00&lt;/p&gt;  &lt;pre class="brush: plain;"&gt;Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\10.0\Debugger]
"DisableAttachSecurityWarning"=dword:00000001

[HKEY_CURRENT_USER\Software\Wow6432Node\Microsoft\VisualStudio\10.0\Debugger]
"DisableAttachSecurityWarning"=dword:00000001&lt;/pre&gt; &lt;img src="http://geekswithblogs.net/cicorias/aggbug/149296.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Shawn Cicoria</dc:creator>
            <guid>http://geekswithblogs.net/cicorias/archive/2012/04/12/turning-off-the-visual-studio-ldquoattach-to-processrdquo-security-warninghellip.aspx</guid>
            <pubDate>Thu, 12 Apr 2012 12:57:49 GMT</pubDate>
            <comments>http://geekswithblogs.net/cicorias/archive/2012/04/12/turning-off-the-visual-studio-ldquoattach-to-processrdquo-security-warninghellip.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/cicorias/comments/commentRss/149296.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/cicorias/services/trackbacks/149296.aspx</trackback:ping>
        </item>
        <item>
            <title>Getting a SecurityToken from a RequestSecurityTokenResponse in WIF</title>
            <link>http://geekswithblogs.net/cicorias/archive/2012/03/22/getting-a-securitytoken-from-a-requestsecuritytokenresponse-in-wif.aspx</link>
            <description>&lt;p&gt;Originally posted on: &lt;a href='http://geekswithblogs.net/cicorias/archive/2012/03/22/getting-a-securitytoken-from-a-requestsecuritytokenresponse-in-wif.aspx'&gt;http://geekswithblogs.net/cicorias/archive/2012/03/22/getting-a-securitytoken-from-a-requestsecuritytokenresponse-in-wif.aspx&lt;/a&gt;&lt;/p&gt;&lt;p&gt;When you’re working with WIF and WSTrustChannelFactory when you call the Issue operation, you can also request that a RequestSecurityTokenResponse as an out parameter.&lt;/p&gt;  &lt;p&gt;However, what can you do with that object?  Well, you could keep it around and use it for subsequent calls with the extension method CreateChannelWithIssuedToken – or can you?&lt;/p&gt;  &lt;pre class="brush: csharp;"&gt;public static T CreateChannelWithIssuedToken&amp;lt;T&amp;gt;(this ChannelFactory&amp;lt;T&amp;gt; factory, SecurityToken issuedToken);&lt;/pre&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;As you can see from the method signature it takes a SecurityToken – but that’s not present on the RequestSecurityTokenResponse class.&lt;/p&gt;

&lt;p&gt;However, you can through a little magic get a GenericXmlSecurityToken by means of the following set of extension methods below – just call &lt;/p&gt;

&lt;p&gt;rstr.GetSecurityTokenFromResponse() – and you’ll get a GenericXmlSecurityToken as a return.&lt;/p&gt;

&lt;pre class="brush: csharp;"&gt;public static class TokenHelper
{


    /// &amp;lt;summary&amp;gt;
    /// Takes a RequestSecurityTokenResponse, pulls out the GenericXmlSecurityToken usable for further WS-Trust calls
    /// &amp;lt;/summary&amp;gt;
    /// &amp;lt;param name="rstr"&amp;gt;&amp;lt;/param&amp;gt;
    /// &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;
    public static GenericXmlSecurityToken GetSecurityTokenFromResponse(this RequestSecurityTokenResponse rstr)
    {
        var lifeTime = rstr.Lifetime;
        var appliesTo = rstr.AppliesTo.Uri;
        var tokenXml = rstr.GetSerializedTokenFromResponse();
        var token = GetTokenFromSerializedToken(tokenXml, appliesTo, lifeTime);
        return token;
    }

    /// &amp;lt;summary&amp;gt;
    /// Provides a token as an XML string.
    /// &amp;lt;/summary&amp;gt;
    /// &amp;lt;param name="rstr"&amp;gt;&amp;lt;/param&amp;gt;
    /// &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;
    public static string GetSerializedTokenFromResponse(this RequestSecurityTokenResponse rstr)
    {
        var serializedRst = new WSFederationSerializer().GetResponseAsString(rstr, new WSTrustSerializationContext());
        return serializedRst;
    }

    /// &amp;lt;summary&amp;gt;
    /// Turns the XML representation of the token back into a GenericXmlSecurityToken.
    /// &amp;lt;/summary&amp;gt;
    /// &amp;lt;param name="tokenAsXmlString"&amp;gt;&amp;lt;/param&amp;gt;
    /// &amp;lt;param name="appliesTo"&amp;gt;&amp;lt;/param&amp;gt;
    /// &amp;lt;param name="lifetime"&amp;gt;&amp;lt;/param&amp;gt;
    /// &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;
    public static GenericXmlSecurityToken GetTokenFromSerializedToken(this string tokenAsXmlString, Uri appliesTo, Lifetime lifetime)
    {
        RequestSecurityTokenResponse rstr2 = new WSFederationSerializer().CreateResponse(
        new SignInResponseMessage(appliesTo, tokenAsXmlString),
        new WSTrustSerializationContext());
        return new GenericXmlSecurityToken(
            rstr2.RequestedSecurityToken.SecurityTokenXml,
            new BinarySecretSecurityToken(
                rstr2.RequestedProofToken.ProtectedKey.GetKeyBytes()),
            lifetime.Created.HasValue ? lifetime.Created.Value : DateTime.MinValue,
            lifetime.Expires.HasValue ? lifetime.Expires.Value : DateTime.MaxValue,
            rstr2.RequestedAttachedReference,
            rstr2.RequestedUnattachedReference,
            null);
    }

}&lt;/pre&gt; &lt;img src="http://geekswithblogs.net/cicorias/aggbug/149084.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Shawn Cicoria</dc:creator>
            <guid>http://geekswithblogs.net/cicorias/archive/2012/03/22/getting-a-securitytoken-from-a-requestsecuritytokenresponse-in-wif.aspx</guid>
            <pubDate>Thu, 22 Mar 2012 21:23:16 GMT</pubDate>
            <comments>http://geekswithblogs.net/cicorias/archive/2012/03/22/getting-a-securitytoken-from-a-requestsecuritytokenresponse-in-wif.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/cicorias/comments/commentRss/149084.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/cicorias/services/trackbacks/149084.aspx</trackback:ping>
        </item>
        <item>
            <title>Making Windows Azure Drive Letter Persistent</title>
            <link>http://geekswithblogs.net/cicorias/archive/2012/01/19/making-windows-azure-drive-letter-persistent.aspx</link>
            <description>&lt;p&gt;Originally posted on: &lt;a href='http://geekswithblogs.net/cicorias/archive/2012/01/19/making-windows-azure-drive-letter-persistent.aspx'&gt;http://geekswithblogs.net/cicorias/archive/2012/01/19/making-windows-azure-drive-letter-persistent.aspx&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Windows Azure Fieldnote&lt;/p&gt;  &lt;h3&gt;Summary&lt;/h3&gt;  &lt;p&gt;Windows Azure Drives [1] provide a means to represent a file based (disk drive) persistent storage option for the various role types within Windows Azure Compute. Each of the roles within Windows Azure can mount and utilize for persistent storage (that survives reboot, reimaging, and updated deployments, of a role instances). &lt;/p&gt;  &lt;p&gt;During the mounting of a VHD as a &lt;b&gt;CloudDrive&lt;/b&gt;, the managed classes have no means to control the drive letter assignment this directly through the &lt;b&gt;CloudDrive&lt;/b&gt; managed classes that are provided through the Windows Azure SDK.&lt;/p&gt;  &lt;h3&gt;Problem&lt;/h3&gt;  &lt;p&gt;Many solutions today require the use of standard Windows File IO based access and instead of refactoring solutions to leverage the storage options available in the PaaS part of the Windows Azure platform, solutions deployed to Windows Azure can mount a Virtual Hard Disk (VHD) that is persisted in a storage account inside of a running instance. That Page Blob backed VHD is then represented through Virtual Disk Services and Windows Cloud Drive services to the running instances as a Disk Drive and addressable through File IO using a Drive Letter.&lt;/p&gt;  &lt;p&gt;While a persistent drive option is available, the drive letter assignment is determined at runtime during the mounting process. This potentially presents a problem with existing solutions, codebases, libraries that require a setting to be established prior to runtime. For example, an application configuration setting that provides a full path, including the drive letter to a location for read/write access for File IO.&lt;/p&gt;  &lt;h3&gt;Solution&lt;/h3&gt;  &lt;p&gt;The following solution takes advantage of the Virtual Disk Services through the &lt;b&gt;DiskPart.exe&lt;/b&gt; operating system utility to first identify what the VHD is mounted as and, select that volume, and re-assign the letter to the target drive letter.&lt;/p&gt;  &lt;p&gt;The original idea for the approach comes from this blog post here: &lt;a href="http://techyfreak.blogspot.com/2011/02/changing-drive-letter-of-azure-drive.html"&gt;http://techyfreak.blogspot.com/2011/02/changing-drive-letter-of-azure-drive.html&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;While there is a COM interface available that could be wrapped via an interop layer, the choice was made to initiate a process to take the actions required for remapping the drive letter due to simplicity. Additionally, while there is an existing managed Interop assembly available (&lt;strong&gt;Microsoft.Storage.Vds&lt;/strong&gt;) that is an undocumented and unsupported assembly.&lt;/p&gt;  &lt;p&gt;The example scenario presented does the following:&lt;/p&gt;  &lt;p&gt;1. Leverages a Windows Azure Web Role (could be a Worker Role or VM Role as well)&lt;/p&gt;  &lt;p&gt;2. Implements a Windows Console applications that:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;a. Is a Startup task – in elevated mode and background&lt;/p&gt;    &lt;p&gt;b. Runs elevated in order to affect Virtual Disk Services&lt;/p&gt;    &lt;p&gt;c. At startup:&lt;/p&gt; &lt;/blockquote&gt;  &lt;ul&gt;   &lt;ul&gt;     &lt;li&gt;Mounts the VHD from Windows Azure Storage &lt;/li&gt;      &lt;li&gt;Detects if target drive letter and re-assigns as needed to target drive letter ** &lt;/li&gt;   &lt;/ul&gt; &lt;/ul&gt;  &lt;blockquote&gt;   &lt;p&gt;d. Then Continuously (every 30 seconds)&lt;/p&gt; &lt;/blockquote&gt;  &lt;ul&gt;   &lt;ul&gt;     &lt;li&gt;i. Checks if drive is mounted on target drive letter &lt;/li&gt;      &lt;li&gt;ii. If not, reassigns drive letter ** &lt;/li&gt;   &lt;/ul&gt; &lt;/ul&gt;  &lt;p&gt;&lt;b&gt;** Drive Letter reassignment is done through a &lt;i&gt;System.Process&lt;/i&gt; startup object that runs Diskpart.exe with a “select volume” and “assign drive letter” command sequence.&lt;/b&gt;&lt;/p&gt;  &lt;h3&gt;Implementation&lt;/h3&gt;  &lt;p&gt;The sample solution contains the following:&lt;/p&gt;  &lt;p&gt;1. Windows Azure Web Role – simple MVC3 application that just lists the mapped &lt;b&gt;CloudDrives&lt;/b&gt; using the &lt;b&gt;CloudDrive.GetMountedDrives()&lt;/b&gt; method&lt;/p&gt;  &lt;p&gt;2. &lt;b&gt;CloudDriveManager&lt;/b&gt; class library – helper class that provides the CloudDrive management actions leveraged by the caller (either Console or other code)&lt;/p&gt;  &lt;p&gt;3. &lt;b&gt;CloudDriveManagerConsole&lt;/b&gt; – Windows console application intended to be a startup project and running in elevated mode in order to affect the assigned driver letter&lt;/p&gt;  &lt;p&gt;4. &lt;b&gt;CloudDriveManagerRole&lt;/b&gt; – implementation of &lt;b&gt;Microsoft.WindowsAzure.ServiceRuntime.RoleEntryPoint&lt;/b&gt; – which allows this class to be used from within a Windows Azure Web or Worker role – however, that role entry point would need to be elevated (via the “&lt;b&gt;Runtime&lt;/b&gt;” and “&lt;b&gt;NetFxEntryPoint&lt;/b&gt;” Elements)&lt;/p&gt;  &lt;p&gt;5. &lt;b&gt;Logger&lt;/b&gt; – simple logger class that writes to a Queue for debugging purposes&lt;/p&gt;  &lt;p&gt;6. &lt;b&gt;ResponseViewer&lt;/b&gt; – simple WPF application that reads Queue messages so you can view log messages from your cloud instances – purely for debugging purposes&lt;/p&gt;  &lt;p&gt;7. &lt;b&gt;TestListDrives&lt;/b&gt; – simple Windows console application that lists the mapped &lt;b&gt;CloudDrives&lt;/b&gt; – usable from within the Role instance by using Remote Desktop and connecting to the instance&lt;/p&gt;  &lt;h4&gt;Instance Initialization&lt;/h4&gt;  &lt;p&gt;During role startup, Windows Azure will execute the Task defined in the Service definition in background mode and elevated (running as system). Inside of the console application, the implementation of &lt;b&gt;OnStart&lt;/b&gt; does the following:&lt;/p&gt;  &lt;pre class="brush: csharp;"&gt;public override bool OnStart()
{
    try
    {
        Initialize();
        MountAllDrives();
    }
    catch (Exception ex)
    {
        _logger.Log("fail on onstart", ex);
    }
    return true;
}

void MountAllDrives()
{
    try
    {
        var driveSettings = RoleEnvironment.GetConfigurationSettingValue(DRIVE_SETTINGS);
        string[] settings = driveSettings.Split(':');
        CloudStorageAccount account =CoudStorageAccount.FromConfigurationSetting(STORAGE_ACCOUNT_SETTING);
        string dCacheName = RoleEnvironment.GetConfigurationSettingValue(DCACHE_NAME);
        LocalResource cache = RoleEnvironment.GetLocalResource(dCacheName);
        int cacheSize = cache.MaximumSizeInMegabytes / 2;
        _cloudDriveManager = new CloudDriveManager(account, settings[0], settings[1][0], cache);
        _cloudDriveManager.CreateDrive();
        _cloudDriveManager.Mount();
    }
    catch (Exception ex)
    {
        _logger.Log("fail on mountalldrives", ex);
        throw;
    }
}&lt;/pre&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;Mostly, the startup routine calls into the custom class &lt;b&gt;CloudDriveManager&lt;/b&gt;, which provides the simple abstraction to the Windows Azure &lt;b&gt;CloudDrive&lt;/b&gt; managed class.&lt;/p&gt;

&lt;p&gt;The custom &lt;b&gt;CreateDrive&lt;/b&gt; method calls the &lt;b&gt;CloudDrive&lt;/b&gt; create drive method in a non-destructive manner – and, for this sample, creates the initial VHD in storage if it does not already exist.&lt;/p&gt;

&lt;p&gt;Mounting calls the managed classes &lt;b&gt;CloudDrive.Moun&lt;/b&gt;t along with calling into a custom &lt;b&gt;VerifyDriveLetter&lt;/b&gt; method.&lt;/p&gt;

&lt;pre class="brush: csharp;"&gt;public void Mount()
{
    _logger.Log(string.Format("mounting drive {0}", _vhdName));
    _cloudDrive = _account.CreateCloudDrive(_vhdName);

    var driveLetter = _cloudDrive.Mount(_cacheSize, DriveMountOptions.Force);
    _logger.Log(string.Format("mounted drive letter {0}", driveLetter));

    var remounted = VerifyDriveLetter();
}&lt;/pre&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;Within &lt;b&gt;VerifyDriveLetter&lt;/b&gt; there’s some logic to validate the current state of the mounted drives. And then verification if the mounted drive is the intended drive letter.&lt;/p&gt;

&lt;pre class="brush: csharp;"&gt;public bool VerifyDriveLetter()
{
    _logger.Log("verifying drive letter");
    bool rv = false;
    if (RoleEnvironment.IsEmulated)
    {
        _logger.Log("Can't change drive letter in emulator");
        //return;
    }

    try
    {
        DriveInfo d = new DriveInfo(_cloudDrive.LocalPath);
        if (string.IsNullOrEmpty(_cloudDrive.LocalPath))
        {
            _logger.Log("verifydriveLetter: Not Mounted?");
            throw new InvalidOperationException("drive is notmounted");
        }

        if (!char.IsLetter(_cloudDrive.LocalPath[0]))
        {
            _logger.Log("verifiydriveLeter: Not a letter?");
            throw new InvalidOperationException("verifydriveletter - not a letter?");
        }

        if (IsSameDrive())
        {
            _logger.Log("is same drive; no need to diskpart...");
            return true;
        }

        char mountedDriveLetter = CurrentLocalDrive(_vhdName);
        RunDiskPart(_driveLetter, mountedDriveLetter);

        if (!IsSameDrive())
        {
            var msg = "Drive change failed to change";
                   _logger.Log(msg);
                   throw new ApplicationException(msg);
               }
               else
               {
                   Mount();
               }

               _logger.Log("verifydriveletter done!!");
               return rv;

           }
           catch (Exception ex)
           {
               _logger.Log("error verifydriveletter", ex);
               return rv;
           }

       }&lt;/pre&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;The &lt;b&gt;IsSameDrive&lt;/b&gt; method validates if the current mapped drive is indeed the planned drive letter. If not, it will return “false”.&lt;/p&gt;

&lt;pre class="brush: csharp;"&gt;bool IsSameDrive()
{
    char targetDrive = _driveLetter.ToString().ToLower()[0];
    char currentDrive = CurrentLocalDrive(_vhdName);

    string msg = string.Format(
        "target drive: {0} - current drive: {1}",
        targetDrive,
        currentDrive);

    _logger.Log(msg);

    if (targetDrive == currentDrive)
    {
        _logger.Log("verifydriveLetter: already same drive");
        return true;
    }
    else
        return false;

}&lt;/pre&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;Finally, the &lt;b&gt;RunDiskPart&lt;/b&gt; method initiates the action of spawning a new process with the dynamically created &lt;b&gt;DiskPart&lt;/b&gt; script file that selects the existing volume name (by drive letter) and assigns the target drive letter.&lt;/p&gt;

&lt;pre class="brush: csharp;"&gt;void RunDiskPart(char destinationDriveLetter, char mountedDriveLetter)
{
    string diskpartFile = Path.Combine(_cache.RootPath, "diskpart.txt");

    if (File.Exists(diskpartFile))
    {
        File.Delete(diskpartFile);
    }

    string cmd = "select volume = " + mountedDriveLetter + "\r\n" + "assign letter = " + destinationDriveLetter;
      File.WriteAllText(diskpartFile, cmd);

      //start the process
      _logger.Log("running diskpart now!!!!");
      _logger.Log("using " + cmd);
      using (Process changeletter = new Process())
      {
          changeletter.StartInfo.Arguments = "/s" + " " + diskpartFile;
          changeletter.StartInfo.FileName = 
     System.Environment.GetEnvironmentVariable("WINDIR") + "\\System32\\diskpart.exe";
        //#if !DEBUG
        changeletter.Start();
        changeletter.WaitForExit();
        //#endif
    }

    File.Delete(diskpartFile);

}&lt;/pre&gt;

&lt;h3&gt;Output and Results&lt;/h3&gt;

&lt;p&gt;As an example of the interaction and how the drive appears within the running Windows Azure Role, the following screen shots illustrate the results.&lt;/p&gt;

&lt;h4&gt;Program Startup&lt;/h4&gt;

&lt;p&gt;At program startup the drive is initially mounted by the Console application – immediately the drive is mounted as the F: drive – the startup code verifies if this is the intended drive – as shown below in the logs, it isn’t, so the code initiates the RunDiskPart method setting M: as the mapped drive.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://gwb.blob.core.windows.net/cicorias/Windows-Live-Writer/Making-Windows-Azure-Drive-Letter-Persis_CFCB/image_2.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://gwb.blob.core.windows.net/cicorias/Windows-Live-Writer/Making-Windows-Azure-Drive-Letter-Persis_CFCB/image_thumb.png" width="574" height="408" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;The following shows how a Windows Azure Drive appears after the custom code reassigns the drive letter to the Operating system using Windows Explorer – the drive is selected below.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://gwb.blob.core.windows.net/cicorias/Windows-Live-Writer/Making-Windows-Azure-Drive-Letter-Persis_CFCB/image_4.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://gwb.blob.core.windows.net/cicorias/Windows-Live-Writer/Making-Windows-Azure-Drive-Letter-Persis_CFCB/image_thumb_1.png" width="576" height="344" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;Within the custom MVC3 application, which simply just lists the Mounted Windows Azure drive (which runs in a separate Process non-elevated – the drive appears as a regular Operating System drive – accessible for File IO as required using the intended drive letter.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://gwb.blob.core.windows.net/cicorias/Windows-Live-Writer/Making-Windows-Azure-Drive-Letter-Persis_CFCB/image_6.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://gwb.blob.core.windows.net/cicorias/Windows-Live-Writer/Making-Windows-Azure-Drive-Letter-Persis_CFCB/image_thumb_2.png" width="572" height="269" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;Forced Letter Change&lt;/h4&gt;

&lt;p&gt;The following shows what happens if the drive letter is intentionally changed – in this example, I just initiate a &lt;b&gt;DiskPart&lt;/b&gt; set of commands to assign the mounted drive the letter L:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://gwb.blob.core.windows.net/cicorias/Windows-Live-Writer/Making-Windows-Azure-Drive-Letter-Persis_CFCB/image_8.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://gwb.blob.core.windows.net/cicorias/Windows-Live-Writer/Making-Windows-Azure-Drive-Letter-Persis_CFCB/image_thumb_3.png" width="575" height="347" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see in the Windows Explorer window the letter now appears as L: for the &lt;b&gt;WindowsAzureDrive&lt;/b&gt;.&lt;/p&gt;

&lt;p&gt;Within approximately 30 seconds (which is the value used in the &lt;b&gt;Run&lt;/b&gt; method by the custom code) &lt;b&gt;VerifyDriveLetter&lt;/b&gt; detects it’s not the intended drive and initiates a change.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://gwb.blob.core.windows.net/cicorias/Windows-Live-Writer/Making-Windows-Azure-Drive-Letter-Persis_CFCB/image_10.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://gwb.blob.core.windows.net/cicorias/Windows-Live-Writer/Making-Windows-Azure-Drive-Letter-Persis_CFCB/image_thumb_4.png" width="584" height="357" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;And the below image shows the drive again, appearing as the M: drive:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://gwb.blob.core.windows.net/cicorias/Windows-Live-Writer/Making-Windows-Azure-Drive-Letter-Persis_CFCB/image_12.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://gwb.blob.core.windows.net/cicorias/Windows-Live-Writer/Making-Windows-Azure-Drive-Letter-Persis_CFCB/image_thumb_5.png" width="615" height="371" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h3&gt;Future Options&lt;/h3&gt;

&lt;p&gt;Since capabilities in the Windows Azure platform change over time the ability to dictate the specific letter to be used may come available. Until then, this approach, by means of the Windows Azure Drive and Virtual Disk Services abstraction provided by the platform offers a means to accommodate codebase and application logic that is dependent upon predetermined drive letters.&lt;/p&gt;

&lt;h3&gt;References&lt;/h3&gt;

&lt;p&gt;[1] Windows Azure Drives &lt;a href="http://www.windowsazure.com/en-us/develop/net/fundamentals/cloud-storage/#drives"&gt;http://www.windowsazure.com/en-us/develop/net/fundamentals/cloud-storage/#drives&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;[2] Virtual Disk Service &lt;a href="http://msdn.microsoft.com/en-us/library/windows/desktop/bb986750(v=vs.85).aspx"&gt;http://msdn.microsoft.com/en-us/library/windows/desktop/bb986750(v=vs.85).aspx&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;[3] CloudDrive Storage Client &lt;a href="http://msdn.microsoft.com/en-us/library/microsoft.windowsazure.storageclient.clouddrive.aspx"&gt;http://msdn.microsoft.com/en-us/library/microsoft.windowsazure.storageclient.clouddrive.aspx&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;[4] Diskpart.exe &lt;a href="http://technet.microsoft.com/en-us/library/cc770877(v=WS.10).aspx"&gt;http://technet.microsoft.com/en-us/library/cc770877(v=WS.10).aspx&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;[5] Task element &lt;a href="http://msdn.microsoft.com/en-us/library/windowsazure/gg557552.aspx#Task"&gt;http://msdn.microsoft.com/en-us/library/windowsazure/gg557552.aspx#Task&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;[6] Runtime element &lt;a href="http://msdn.microsoft.com/en-us/library/windowsazure/gg557552.aspx#Runtime"&gt;http://msdn.microsoft.com/en-us/library/windowsazure/gg557552.aspx#Runtime&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;[7] NetFxEntryPoint element &lt;a href="http://msdn.microsoft.com/en-us/library/windowsazure/gg557552.aspx#NetFxEntryPoint"&gt;http://msdn.microsoft.com/en-us/library/windowsazure/gg557552.aspx#NetFxEntryPoint&lt;/a&gt;&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;&lt;a title="http://cicoria.com/downloads/waz/MountXDriveSameLetter.zip" href="http://cicoria.com/downloads/waz/MountXDriveSameLetter.zip"&gt;Solution File: MountXDriveSameLetter.zip&lt;/a&gt;&lt;/p&gt; &lt;img src="http://geekswithblogs.net/cicorias/aggbug/148428.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Shawn Cicoria</dc:creator>
            <guid>http://geekswithblogs.net/cicorias/archive/2012/01/19/making-windows-azure-drive-letter-persistent.aspx</guid>
            <pubDate>Thu, 19 Jan 2012 20:46:43 GMT</pubDate>
            <comments>http://geekswithblogs.net/cicorias/archive/2012/01/19/making-windows-azure-drive-letter-persistent.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/cicorias/comments/commentRss/148428.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/cicorias/services/trackbacks/148428.aspx</trackback:ping>
        </item>
        <item>
            <title>Viewing the User Token from Visual Studio 2010 Debugger</title>
            <link>http://geekswithblogs.net/cicorias/archive/2011/12/06/viewing-the-user-token-from-visual-studio-2010-debugger.aspx</link>
            <description>&lt;p&gt;Originally posted on: &lt;a href='http://geekswithblogs.net/cicorias/archive/2011/12/06/viewing-the-user-token-from-visual-studio-2010-debugger.aspx'&gt;http://geekswithblogs.net/cicorias/archive/2011/12/06/viewing-the-user-token-from-visual-studio-2010-debugger.aspx&lt;/a&gt;&lt;/p&gt;&lt;p&gt;When you’re debugging security related things, sometimes you need to take a look at the thread identities user token.&lt;/p&gt;  &lt;p&gt;When you’re inside of Visual Studio 2010 – in the watch windows you enter ‘$user’  and you’ll get the same as when in windbg with !token –n&lt;/p&gt;  &lt;p&gt; &lt;/p&gt;  &lt;p&gt;&lt;a href="http://gwb.blob.core.windows.net/cicorias/Windows-Live-Writer/a572807ec351_FBF6/SNAGHTML6a3d6356.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="SNAGHTML6a3d635[6]" border="0" alt="SNAGHTML6a3d635[6]" src="http://gwb.blob.core.windows.net/cicorias/Windows-Live-Writer/a572807ec351_FBF6/SNAGHTML6a3d6356_thumb.png" width="530" height="171" /&gt;&lt;/a&gt;&lt;/p&gt; &lt;img src="http://geekswithblogs.net/cicorias/aggbug/147959.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Shawn Cicoria</dc:creator>
            <guid>http://geekswithblogs.net/cicorias/archive/2011/12/06/viewing-the-user-token-from-visual-studio-2010-debugger.aspx</guid>
            <pubDate>Tue, 06 Dec 2011 23:01:49 GMT</pubDate>
            <comments>http://geekswithblogs.net/cicorias/archive/2011/12/06/viewing-the-user-token-from-visual-studio-2010-debugger.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/cicorias/comments/commentRss/147959.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/cicorias/services/trackbacks/147959.aspx</trackback:ping>
        </item>
        <item>
            <title>Microsoft TechNet&amp;ndash;Create PDF Takeaway chapters for your set of topics&amp;ndash;great feature just added..</title>
            <link>http://geekswithblogs.net/cicorias/archive/2011/11/30/microsoft-technetndashcreate-pdf-takeaway-chapters-for-your-set-of-topicsndashgreat.aspx</link>
            <description>&lt;p&gt;Originally posted on: &lt;a href='http://geekswithblogs.net/cicorias/archive/2011/11/30/microsoft-technetndashcreate-pdf-takeaway-chapters-for-your-set-of-topicsndashgreat.aspx'&gt;http://geekswithblogs.net/cicorias/archive/2011/11/30/microsoft-technetndashcreate-pdf-takeaway-chapters-for-your-set-of-topicsndashgreat.aspx&lt;/a&gt;&lt;/p&gt;&lt;p&gt;If you’re like me, having those PDF version for offline review are great.  It was a pain before as I had to individually print web pages to single PDF using tools.&lt;/p&gt;  &lt;p&gt;Now, TechNet can track a “book” of topics for you, and then generate HTML or PDF for you to download – personal publishing &lt;img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-smile" alt="Smile" src="http://gwb.blob.core.windows.net/cicorias/Windows-Live-Writer/Microsoft-TechNetCreate-PDF-Takeaway-ch_9295/wlEmoticon-smile_2.png" /&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.technet.com/b/tonyso/archive/2011/09/13/roll-your-own-techdocs.aspx"&gt;Roll-your-own techdocs for free - TONYSO - Site Home - TechNet Blogs&lt;/a&gt;&lt;/p&gt; &lt;img src="http://geekswithblogs.net/cicorias/aggbug/147891.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Shawn Cicoria</dc:creator>
            <guid>http://geekswithblogs.net/cicorias/archive/2011/11/30/microsoft-technetndashcreate-pdf-takeaway-chapters-for-your-set-of-topicsndashgreat.aspx</guid>
            <pubDate>Wed, 30 Nov 2011 15:26:20 GMT</pubDate>
            <comments>http://geekswithblogs.net/cicorias/archive/2011/11/30/microsoft-technetndashcreate-pdf-takeaway-chapters-for-your-set-of-topicsndashgreat.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/cicorias/comments/commentRss/147891.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/cicorias/services/trackbacks/147891.aspx</trackback:ping>
        </item>
        <item>
            <title>Dennis Ritchie, Father of C and Co-Developer of Unix, Dies | Wired Enterprise | Wired.com</title>
            <link>http://geekswithblogs.net/cicorias/archive/2011/10/14/dennis-ritchie-father-of-c-and-co-developer-of-unix-dies.aspx</link>
            <description>&lt;p&gt;Originally posted on: &lt;a href='http://geekswithblogs.net/cicorias/archive/2011/10/14/dennis-ritchie-father-of-c-and-co-developer-of-unix-dies.aspx'&gt;http://geekswithblogs.net/cicorias/archive/2011/10/14/dennis-ritchie-father-of-c-and-co-developer-of-unix-dies.aspx&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Wow – I still have my &lt;a href="http://www.amazon.com/Programming-Language-2nd-Brian-Kernighan/dp/0131103628/ref=sr_1_1?ie=UTF8&amp;amp;qid=1318603382&amp;amp;sr=8-1" target="_blank"&gt;K&amp;amp;R book&lt;/a&gt; from a class I took at AT&amp;amp;T.  Cut my teeth on nix…&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.wired.com/wiredenterprise/2011/10/dennis-ritchie/"&gt;Dennis Ritchie, Father of C and Co-Developer of Unix, Dies | Wired Enterprise | Wired.com&lt;/a&gt;&lt;/p&gt; &lt;img src="http://geekswithblogs.net/cicorias/aggbug/147308.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Shawn Cicoria</dc:creator>
            <guid>http://geekswithblogs.net/cicorias/archive/2011/10/14/dennis-ritchie-father-of-c-and-co-developer-of-unix-dies.aspx</guid>
            <pubDate>Fri, 14 Oct 2011 14:43:46 GMT</pubDate>
            <comments>http://geekswithblogs.net/cicorias/archive/2011/10/14/dennis-ritchie-father-of-c-and-co-developer-of-unix-dies.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/cicorias/comments/commentRss/147308.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/cicorias/services/trackbacks/147308.aspx</trackback:ping>
        </item>
        <item>
            <title>Description of Update Rollup 1 for Active Directory Federation Services (AD FS) 2.0</title>
            <link>http://geekswithblogs.net/cicorias/archive/2011/10/13/description-of-update-rollup-1-for-active-directory-federation-services.aspx</link>
            <description>&lt;p&gt;Originally posted on: &lt;a href='http://geekswithblogs.net/cicorias/archive/2011/10/13/description-of-update-rollup-1-for-active-directory-federation-services.aspx'&gt;http://geekswithblogs.net/cicorias/archive/2011/10/13/description-of-update-rollup-1-for-active-directory-federation-services.aspx&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Multiple UPN support now available…&lt;/p&gt;  &lt;p&gt;&lt;a href="http://support.microsoft.com/kb/2607496"&gt;Description of Update Rollup 1 for Active Directory Federation Services (AD FS) 2.0&lt;/a&gt;&lt;/p&gt; &lt;img src="http://geekswithblogs.net/cicorias/aggbug/147284.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Shawn Cicoria</dc:creator>
            <guid>http://geekswithblogs.net/cicorias/archive/2011/10/13/description-of-update-rollup-1-for-active-directory-federation-services.aspx</guid>
            <pubDate>Thu, 13 Oct 2011 12:57:08 GMT</pubDate>
            <comments>http://geekswithblogs.net/cicorias/archive/2011/10/13/description-of-update-rollup-1-for-active-directory-federation-services.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/cicorias/comments/commentRss/147284.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/cicorias/services/trackbacks/147284.aspx</trackback:ping>
        </item>
        <item>
            <title>Additional Mime Types in Visual Studio 2010 Development Web Server</title>
            <category>Utilities</category>
            <category>.NET</category>
            <link>http://geekswithblogs.net/cicorias/archive/2011/10/06/additional-mime-types-in-visual-studio-2010-development-web-server.aspx</link>
            <description>&lt;p&gt;Originally posted on: &lt;a href='http://geekswithblogs.net/cicorias/archive/2011/10/06/additional-mime-types-in-visual-studio-2010-development-web-server.aspx'&gt;http://geekswithblogs.net/cicorias/archive/2011/10/06/additional-mime-types-in-visual-studio-2010-development-web-server.aspx&lt;/a&gt;&lt;/p&gt;&lt;p&gt;While the development server in Visual Studio 2010 is great for most work, it does have 1 shortcoming in that if you start adding content types that are not part of the base set of known Mime types built in, you won’t affect the proper header response that is emitted to the client/browser.&lt;/p&gt;  &lt;p&gt;For example MP4 files, out of the box the development web server emits application/octet-stream or something like that.  What we really need is video/mp4.&lt;/p&gt;  &lt;p&gt;Now, with IIS Express, you can easily switch over to use that and just add the correct mapping to the section of the web.config when you’re running in integrated mode.  Such as follows:&lt;/p&gt;  &lt;pre class="brush: xml;"&gt;&amp;lt;system.webServer&amp;gt;
  &amp;lt;modules runAllManagedModulesForAllRequests="true" /&amp;gt;
  &amp;lt;staticContent&amp;gt;
    &amp;lt;mimeMap fileExtension=".mp4" mimeType="video/mp4" /&amp;gt;
    &amp;lt;mimeMap fileExtension=".m4v" mimeType="video/m4v" /&amp;gt;
  &amp;lt;/staticContent&amp;gt;
&amp;lt;/system.webServer&amp;gt;&lt;/pre&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;However, with the Visual Studio 2010 built in Web Development server, you can’t affect the mime type support through configuration. &lt;/p&gt;

&lt;p&gt;For this a simple NuGet package is available that provides a simple HttpModule to affect the ContentType on the response headers.  it reads the Web.config for the site and will honor the section above – this all happens only when NOT running in Integrated Pipeline mode.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://gwb.blob.core.windows.net/cicorias/Windows-Live-Writer/8ff5cadfdce3_1025C/image_2.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://gwb.blob.core.windows.net/cicorias/Windows-Live-Writer/8ff5cadfdce3_1025C/image_thumb.png" width="418" height="49" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://gwb.blob.core.windows.net/cicorias/Windows-Live-Writer/8ff5cadfdce3_1025C/SNAGHTML6f59550.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="SNAGHTML6f59550" border="0" alt="SNAGHTML6f59550" src="http://gwb.blob.core.windows.net/cicorias/Windows-Live-Writer/8ff5cadfdce3_1025C/SNAGHTML6f59550_thumb.png" width="548" height="274" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Sample Solution and Source here: &lt;a href="http://cicoria.com/downloads/SampleMimeHelper.zip"&gt;SampleMimeHelper.zip&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The HttpModule makes use of dynamically loading via the &lt;a href="http://msdn.microsoft.com/en-us/library/system.web.preapplicationstartmethodattribute.aspx" target="_blank"&gt;PreApplicationStartMethod&lt;/a&gt; and the &lt;a href="http://msdn.microsoft.com/en-us/library/microsoft.web.infrastructure.dynamicmodulehelper.dynamicmoduleutility.registermodule.aspx" target="_blank"&gt;DynamicModuleHelper&lt;/a&gt; utility method that is part of the Microsoft.Web.Infrastructure namespace. &lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;pre class="brush: csharp;"&gt;using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Diagnostics;
using System.Configuration;
using System.Web.Configuration;
using System.Xml.Linq;
using Microsoft.Web.Infrastructure.DynamicModuleHelper;

[assembly: PreApplicationStartMethod(typeof(MimeHelper), "Start")]

/// &amp;lt;summary&amp;gt;
/// Summary description for MimeHelper
/// &amp;lt;/summary&amp;gt;
public class MimeHelper : IHttpModule
{
    static Dictionary&amp;lt;string, string&amp;gt; s_mimeMappings;
    static object s_lockObject = new object();

    public static void Start()
    {
        if ( ! HttpRuntime.UsingIntegratedPipeline)
            DynamicModuleUtility.RegisterModule(typeof(MimeHelper));
    }

    static string GetMimeType(HttpContext context)
    {
        var ext = VirtualPathUtility.GetExtension(context.Request.Url.ToString());
        if (string.IsNullOrEmpty(ext)) return null;

        CreateMapping(context.ApplicationInstance);

        string mimeType = null;
        s_mimeMappings.TryGetValue(ext, out mimeType);

        return mimeType;

    }

    static void CreateMapping(HttpApplication app)
    {
        if (null == s_mimeMappings)
        {
            lock (s_lockObject)
            {
                if (null == s_mimeMappings)
                {
                    string path = app.Server.MapPath("~/web.config");
                    XDocument doc = XDocument.Load(path);

                    var s = from v in doc.Descendants("system.webServer").Descendants("staticContent").Descendants("mimeMap")
                            select new { mimeType = v.Attribute("mimeType").Value, fileExt = v.Attribute("fileExtension").Value };

                    s_mimeMappings = new Dictionary&amp;lt;string, string&amp;gt;();
                    foreach (var item in s)
                    {
                        s_mimeMappings.Add(item.fileExt.ToString(), item.mimeType.ToString());
                    }
                }
            }
        }
    }


    public void Dispose() { }

    public void Init(HttpApplication context)
    {
        context.EndRequest += new EventHandler(context_EndRequest);
    }

    void context_EndRequest(object sender, EventArgs e)
    {
        try
        {
            HttpApplication app = sender as HttpApplication;
            string mimeType = GetMimeType(app.Context);

            if (null == mimeType) return;

            app.Context.Response.ContentType = mimeType;
        }
        catch (Exception ex)
        {
            Debug.WriteLine(ex.Message);
        }
    }
}&lt;/pre&gt; &lt;img src="http://geekswithblogs.net/cicorias/aggbug/147202.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Shawn Cicoria</dc:creator>
            <guid>http://geekswithblogs.net/cicorias/archive/2011/10/06/additional-mime-types-in-visual-studio-2010-development-web-server.aspx</guid>
            <pubDate>Thu, 06 Oct 2011 22:40:43 GMT</pubDate>
            <comments>http://geekswithblogs.net/cicorias/archive/2011/10/06/additional-mime-types-in-visual-studio-2010-development-web-server.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/cicorias/comments/commentRss/147202.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/cicorias/services/trackbacks/147202.aspx</trackback:ping>
        </item>
        <item>
            <title>Faking SPContext&amp;ndash;for testing only&amp;hellip;</title>
            <category>SharePoint</category>
            <link>http://geekswithblogs.net/cicorias/archive/2011/09/21/faking-spcontextndashfor-testing-onlyhellip.aspx</link>
            <description>&lt;p&gt;Originally posted on: &lt;a href='http://geekswithblogs.net/cicorias/archive/2011/09/21/faking-spcontextndashfor-testing-onlyhellip.aspx'&gt;http://geekswithblogs.net/cicorias/archive/2011/09/21/faking-spcontextndashfor-testing-onlyhellip.aspx&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Keith Dahlby has a good post on creating a fake SPContext.  Here’s the link and the code&lt;/p&gt;  &lt;p&gt;NOTE: This is not production safe code – use at own risk…&lt;/p&gt;  &lt;p&gt;&lt;a title="http://solutionizing.net/2009/02/16/faking-spcontext/" href="http://solutionizing.net/2009/02/16/faking-spcontext/"&gt;http://solutionizing.net/2009/02/16/faking-spcontext/&lt;/a&gt;&lt;/p&gt;  &lt;pre class="brush: csharp;"&gt;public static SPContext FakeSPContext(SPWeb contextWeb)
{
  // Ensure HttpContext.Current
  if (HttpContext.Current == null)
  {
    HttpRequest request = new HttpRequest("", web.Url, "");
    HttpContext.Current = new HttpContext(request,
      new HttpResponse(TextWriter.Null));
  }

  // SPContext is based on SPControl.GetContextWeb(), which looks here
  if(HttpContext.Current.Items["HttpHandlerSPWeb"] == null)
    HttpContext.Current.Items["HttpHandlerSPWeb"] = web;

  return SPContext.Current;
}&lt;/pre&gt; &lt;img src="http://geekswithblogs.net/cicorias/aggbug/146988.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Shawn Cicoria</dc:creator>
            <guid>http://geekswithblogs.net/cicorias/archive/2011/09/21/faking-spcontextndashfor-testing-onlyhellip.aspx</guid>
            <pubDate>Wed, 21 Sep 2011 21:55:05 GMT</pubDate>
            <comments>http://geekswithblogs.net/cicorias/archive/2011/09/21/faking-spcontextndashfor-testing-onlyhellip.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/cicorias/comments/commentRss/146988.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/cicorias/services/trackbacks/146988.aspx</trackback:ping>
        </item>
        <item>
            <title>Use an Action delegate to time a method&amp;hellip;</title>
            <category>.NET</category>
            <link>http://geekswithblogs.net/cicorias/archive/2011/09/21/use-an-action-delegate-to-time-a-methodhellip.aspx</link>
            <description>&lt;p&gt;Originally posted on: &lt;a href='http://geekswithblogs.net/cicorias/archive/2011/09/21/use-an-action-delegate-to-time-a-methodhellip.aspx'&gt;http://geekswithblogs.net/cicorias/archive/2011/09/21/use-an-action-delegate-to-time-a-methodhellip.aspx&lt;/a&gt;&lt;/p&gt;&lt;p&gt;I wanted an ability to be able to simply time methods and write to a log/trace sink and a very simple approach that I ended up using was to provide a method that takes an Action delegate which would be the method that is to be timed.&lt;/p&gt;  &lt;p&gt;The following is what I came up with (this is my reminder…)&lt;/p&gt;  &lt;pre class="brush: csharp;"&gt;class Program
{
    static void Main(string[] args)
    {
        TestMethod1();
    }

    private static void TestMethod1()
    {
        LoggingHelper.TimeThis("doing something", () =&amp;gt;
        {
            Console.WriteLine("This is the Real Method Body");
            Thread.Sleep(100);
        });
    }
}

public static class LoggingHelper
{
    public static void TimeThis(string message, Action action)
    {
        string methodUnderTimer = GetMethodCalled(1);
        Stopwatch sw = Stopwatch.StartNew();
        LogMessage( string.Format("started: {0} : {1}", methodUnderTimer, message));
        action();
        sw.Stop();
        LogMessage(string.Format("ended  : {0} : {1} : elapsed : {2}", methodUnderTimer, message, sw.Elapsed));

    }

    private static string GetMethodCalled(int stackLevel)
    {
        StackTrace stackTrace = new StackTrace();
        StackFrame stackFrame = stackTrace.GetFrame(stackLevel + 1);
        MethodBase methodBase = stackFrame.GetMethod();
        return methodBase.Name;
    }

    static void LogMessage(string message){
        Console.WriteLine("{0}", message);
    }

}&lt;/pre&gt; &lt;img src="http://geekswithblogs.net/cicorias/aggbug/146987.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Shawn Cicoria</dc:creator>
            <guid>http://geekswithblogs.net/cicorias/archive/2011/09/21/use-an-action-delegate-to-time-a-methodhellip.aspx</guid>
            <pubDate>Wed, 21 Sep 2011 19:15:43 GMT</pubDate>
            <comments>http://geekswithblogs.net/cicorias/archive/2011/09/21/use-an-action-delegate-to-time-a-methodhellip.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/cicorias/comments/commentRss/146987.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/cicorias/services/trackbacks/146987.aspx</trackback:ping>
        </item>
        <item>
            <title>Building scalable web applications with Windows Azure (ed. and on premise too!)</title>
            <link>http://geekswithblogs.net/cicorias/archive/2011/09/20/building-scalable-web-applications-with-windows-azure-ed.-and-on.aspx</link>
            <description>&lt;p&gt;Originally posted on: &lt;a href='http://geekswithblogs.net/cicorias/archive/2011/09/20/building-scalable-web-applications-with-windows-azure-ed.-and-on.aspx'&gt;http://geekswithblogs.net/cicorias/archive/2011/09/20/building-scalable-web-applications-with-windows-azure-ed.-and-on.aspx&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Matthew Kerner’s session at BUILD covers many of the patterns and approaches that a well designed and highly scalable solution can do to make the most efficient use of the platform.&lt;/p&gt;  &lt;p&gt;Truth is many of the areas Matthew covers should be for on Premise too – including use of Windows Azure CDN.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-smile" alt="Smile" src="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-99-56-metablogapi/6663.wlEmoticon_2D00_smile_5F00_74EDC6B3.png" /&gt;  At about ~30:00 in Matthew references one of my posts on Windows Azure CDN and using it with your Compute role (hosted service) as an CDN origin…&lt;/strong&gt;&lt;/p&gt; &lt;object type="application/x-silverlight-2" data="data:application/x-silverlight-2," width="600" height="350"&gt;&lt;param name="minRuntimeVersion" value="4.0.50401.0" /&gt;&lt;param name="source" value="http://channel9.msdn.com/scripts/Channel9.xap?v=1.8" /&gt;&lt;param name="initParams" value="mediaurl=http://video.ch9.ms/build/2011/wmv/870.wmv,thumbnail=http://video.ch9.ms/build/2011/thumbs/870_LG.jpg,deliverymethod=progressivedownload,autoplay=false,entryid=86b50d5e59c4470fa4079f5d00bc8575" /&gt;&lt;/object&gt; &lt;img src="http://geekswithblogs.net/cicorias/aggbug/146959.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Shawn Cicoria</dc:creator>
            <guid>http://geekswithblogs.net/cicorias/archive/2011/09/20/building-scalable-web-applications-with-windows-azure-ed.-and-on.aspx</guid>
            <pubDate>Tue, 20 Sep 2011 12:08:09 GMT</pubDate>
            <comments>http://geekswithblogs.net/cicorias/archive/2011/09/20/building-scalable-web-applications-with-windows-azure-ed.-and-on.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/cicorias/comments/commentRss/146959.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/cicorias/services/trackbacks/146959.aspx</trackback:ping>
        </item>
        <item>
            <title>Comparison of Windows Azure Storage Queues and Service Bus Queues &amp;laquo; Microsoft Technologies Rocks !!!</title>
            <link>http://geekswithblogs.net/cicorias/archive/2011/09/20/comparison-of-windows-azure-storage-queues-and-service-bus-queues.aspx</link>
            <description>&lt;p&gt;Originally posted on: &lt;a href='http://geekswithblogs.net/cicorias/archive/2011/09/20/comparison-of-windows-azure-storage-queues-and-service-bus-queues.aspx'&gt;http://geekswithblogs.net/cicorias/archive/2011/09/20/comparison-of-windows-azure-storage-queues-and-service-bus-queues.aspx&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Nice table comparing Windows Azure Queues vs. Windows Azure AppFabric Service Bus – note the comment regarding in WAZ SDK 1.5 Queue message size is now 64KB&lt;/p&gt;  &lt;p&gt;Of course, I like the name of the blog too.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://preps2.wordpress.com/2011/09/17/comparison-of-windows-azure-storage-queues-and-service-bus-queues/"&gt;Comparison of Windows Azure Storage Queues and Service Bus Queues « Microsoft Technologies Rocks !!!&lt;/a&gt;&lt;/p&gt; &lt;img src="http://geekswithblogs.net/cicorias/aggbug/146958.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Shawn Cicoria</dc:creator>
            <guid>http://geekswithblogs.net/cicorias/archive/2011/09/20/comparison-of-windows-azure-storage-queues-and-service-bus-queues.aspx</guid>
            <pubDate>Tue, 20 Sep 2011 12:07:23 GMT</pubDate>
            <comments>http://geekswithblogs.net/cicorias/archive/2011/09/20/comparison-of-windows-azure-storage-queues-and-service-bus-queues.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/cicorias/comments/commentRss/146958.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/cicorias/services/trackbacks/146958.aspx</trackback:ping>
        </item>
        <item>
            <title>Bringing Hyper-V to &amp;ldquo;Windows 8&amp;rdquo; - Building Windows 8 - Site Home - MSDN Blogs</title>
            <link>http://geekswithblogs.net/cicorias/archive/2011/09/07/bringing-hyper-v-to-ldquowindows-8rdquo---building-windows-8.aspx</link>
            <description>&lt;p&gt;Originally posted on: &lt;a href='http://geekswithblogs.net/cicorias/archive/2011/09/07/bringing-hyper-v-to-ldquowindows-8rdquo---building-windows-8.aspx'&gt;http://geekswithblogs.net/cicorias/archive/2011/09/07/bringing-hyper-v-to-ldquowindows-8rdquo---building-windows-8.aspx&lt;/a&gt;&lt;/p&gt;&lt;p&gt;This is huge – and a welcomed addition.  Been waiting too long for this.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/b/b8/archive/2011/09/07/bringing-hyper-v-to-windows-8.aspx"&gt;Bringing Hyper-V to “Windows 8” - Building Windows 8 - Site Home - MSDN Blogs&lt;/a&gt;&lt;/p&gt; &lt;img src="http://geekswithblogs.net/cicorias/aggbug/146790.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Shawn Cicoria</dc:creator>
            <guid>http://geekswithblogs.net/cicorias/archive/2011/09/07/bringing-hyper-v-to-ldquowindows-8rdquo---building-windows-8.aspx</guid>
            <pubDate>Wed, 07 Sep 2011 21:28:20 GMT</pubDate>
            <comments>http://geekswithblogs.net/cicorias/archive/2011/09/07/bringing-hyper-v-to-ldquowindows-8rdquo---building-windows-8.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/cicorias/comments/commentRss/146790.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/cicorias/services/trackbacks/146790.aspx</trackback:ping>
        </item>
    </channel>
</rss>