<?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:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" version="2.0">
  <channel>
    <title>Brian Mishler on .Net - Asp.Net</title>
    <link>http://mishler.net/</link>
    <description />
    <language>en-us</language>
    <copyright>Brian Mishler</copyright>
    <lastBuildDate>Thu, 27 Apr 2006 12:28:52 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.3.9074.18820</generator>
    <managingEditor>bmishler@qualitydata.com</managingEditor>
    <webMaster>bmishler@qualitydata.com</webMaster>
    <item>
      <trackback:ping>http://mishler.net/Trackback.aspx?guid=754bd904-454a-478e-8b34-fe2b6e30608c</trackback:ping>
      <pingback:server>http://mishler.net/pingback.aspx</pingback:server>
      <pingback:target>http://mishler.net/PermaLink,guid,754bd904-454a-478e-8b34-fe2b6e30608c.aspx</pingback:target>
      <dc:creator>Brian Mishler</dc:creator>
      <wfw:comment>http://mishler.net/CommentView,guid,754bd904-454a-478e-8b34-fe2b6e30608c.aspx</wfw:comment>
      <wfw:commentRss>http://mishler.net/SyndicationService.asmx/GetEntryCommentsRss?guid=754bd904-454a-478e-8b34-fe2b6e30608c</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p class="MsoNormal">
          <span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">In an Asp.Net application, if you
check the properties of the various Asp.Net providers at runtime, you will get a value
that is something of a hybrid between default and custom settings. Similarly, if you
check a property such as </span>
          <span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">ConfigurationManager.ConnectionStrings(“LocalSqlServer”).ConnectionString</span>
          <span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">,
you will get a value that may originate in web.config or result from a default setting.</span>
        </p>
        <p class="MsoNormal">
          <b>
            <span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">Why is this?</span>
          </b>
        </p>
        <p class="MsoNormal">
          <span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">When an Asp.Net 2.0 application
is loaded, the attributes (and behavior) of the various Asp.Net providers (membership,
roleManager, profile and others) are retrieved from sections in machine.config (C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIG\machine.config.) 
If the web application includes a web.config file, the configuration sections contained
therein may supplement or override the default behavior.</span>
        </p>
        <p class="MsoNormal">
          <b>
            <span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial">So how do you programmatically
determine if a provider is getting its configuration from the default (machine.config)
file or from an application-specific (web.config) file? </span>
          </b>
        </p>
        <p class="MsoNormal">
          <span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">I recently had to deal with this
issue in testing for various potential user problems with the <a title="http://www.qualitydata.com/products/aspnet-membership/default.aspx" href="http://www.qualitydata.com/products/aspnet-membership/default.aspx"><font color="#800080">Membership
Manager Control</font></a>.  I was simulating a fairly common scenario where
users might configure their AspNetSqlMembershipProvider to store passwords in an encrypted
format but forget to provide a machineKey section.  The machineKey section defines
how to encrypt/decrypt various types of information and, if not defined in web.config,
will produce autogenerated values. Anyone who has tried to go with an encrypted rather
than hashed passwordFormat will have undoubtedly encountered the following message
when they attempt to run the web application:</span>
        </p>
        <p class="MsoNormal" style="MARGIN-LEFT: 0.5in">
          <i>
            <span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">You must specify a non-autogenerated
machine key to store passwords in the encrypted format. Either specify a different
passwordFormat, or change the machineKey configuration to use a non-autogenerated
decryption key.</span>
          </i>
        </p>
        <p class="MsoNormal">
          <span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">This exception is thrown by the
AspNetSQLMembershipProvider to force the web application developer to provide a machineKey
section in web.config.  This requirement is well documented and several excellent
resources are available on the Internet to help you generate the elements needed to
create your own custom machineKey configuration section.</span>
        </p>
        <p class="MsoNormal">
          <span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">So in my situation, I wanted to
prevent users from changing an individual member’s passwordFormat to Encrypted if
the machineKey was not specified in web.config. I would need a way to determine this
at runtime.  </span>
        </p>
        <p class="MsoNormal">
          <span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">Well, it’s easy enough to get a
strongly typed MachineKeySection object. The following VB.Net method illustrates how
to get an instance of the machineKeySection class for the current web project:</span>
        </p>
        <p class="MsoNormal">
          <span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">        <span style="COLOR: blue">Public</span><span style="COLOR: blue">Shared</span><span style="COLOR: blue">Function</span> GetMachineKeySection() <span style="COLOR: blue">As</span> System.Web.Configuration.MachineKeySection</span>
        </p>
        <p class="MsoNormal">
          <span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">            <span style="COLOR: blue">Static</span> section <span style="COLOR: blue">As</span> MachineKeySection<br /></span>
          <span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">            <span style="COLOR: blue">If</span> section <span style="COLOR: blue">Is</span><span style="COLOR: blue">Nothing</span><span style="COLOR: blue">Then</span></span>
        </p>
        <p class="MsoNormal">
          <span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">               
section = <span style="COLOR: blue">CType</span>(System.Web.Configuration.WebConfigurationManager.GetSection(<span style="COLOR: maroon">"system.web/machineKey"</span>),
MachineKeySection)</span>
        </p>
        <p class="MsoNormal">
          <span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">            <span style="COLOR: blue">End</span><span style="COLOR: blue">If<br /></span></span>
          <span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">            <span style="COLOR: blue">Return</span> section</span>
        </p>
        <p class="MsoNormal">
          <span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">        <span style="COLOR: blue">End</span><span style="COLOR: blue">Function</span></span>
        </p>
        <p class="MsoNormal">
          <span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">(Note that </span>
          <span style="FONT-SIZE: 10pt; COLOR: maroon; FONT-FAMILY: 'Courier New'">"system.web/machineKey"</span>
          <span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"> is
case sensitive)</span>
        </p>
        <p class="MsoNormal">
          <span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">And when you check the resulting
instance, you will get information in fields such as decryption, decryptionKey, validation
and validationKey – whether or not a machineKey section exists in web.config.  </span>
        </p>
        <p class="MsoNormal">
          <b>
            <span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
            </span>
          </b> 
</p>
        <p class="MsoNormal">
          <b>
            <span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">So how can you programmatically
tell if machineKey contains a non-autogenerated decryption key?</span>
          </b>
        </p>
        <p class="MsoNormal">
          <span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">The <em>ElementInformation</em> class
is typically available as a property of sections such as machineKey and can tell you
if a particular element is a collection, if it can be modified and even the line number
where it is defined in its configuration file. And, of course, Microsoft gives us
the IsPresent property which tells us whether or not the element actually exists in
the configuration file. ElementInformation.IsPresent returns a Boolean and is easy
to use as shown in the VB.Net method listed below.</span>
        </p>
        <p class="MsoNormal">
          <span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">        <span style="COLOR: blue">Public</span><span style="COLOR: blue">Shared</span><span style="COLOR: blue">Function</span> HaveMachineKey() <span style="COLOR: blue">As</span><span style="COLOR: blue">Boolean</span></span>
        </p>
        <p class="MsoNormal">
          <span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">            <span style="COLOR: blue">Dim</span> section<span style="COLOR: blue"> As</span> MachineKeySection
= GetMachineKeySection() ' see above </span>
        </p>
        <p class="MsoNormal">
          <span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">            <span style="COLOR: blue">If</span><span style="COLOR: blue">Not</span> section<span style="COLOR: blue"> Is</span><span style="COLOR: blue">Nothing</span><span style="COLOR: blue">Then</span> <br />
               </span>
          <span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">section.ElementInformation.IsPresent<br /></span>
          <span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">            <font color="#0000ff">End
If</font></span>
        </p>
        <p class="MsoNormal">
          <span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">        <span style="COLOR: blue">End</span><span style="COLOR: blue">Function</span></span>
        </p>
        <p class="MsoNormal">
          <span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">The model for strongly typed configuration
classes has been around since .Net 1.0 and is available for WinForms as well as WebForms
applications. Custom configuration classes are relatively easy to create and provide
a big step up from INI files.  In the 2.0 .Net Framework, configuration classes
are even easier to create and provide lots of great new capabilities. This ability
to inherit and override configuration settings does a great job in supporting the
provider model and features such as the <strong>ElementInformation</strong> class
give the programmer all the information he/she needs to determine the source of any
particular configuration section.</span>
        </p>
        <p class="MsoNormal">
          <span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
          </span>
          <span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
          </span>
          <span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
          </span> 
</p>
        <div>
          <p class="MsoAutoSig">
            <span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">Brian Mishler</span>
          </p>
          <p class="MsoAutoSig">
            <span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
              <a title="http://www.qualitydata.com/" href="http://www.qualitydata.com/">
                <font color="#800080">http://www.qualitydata.com</font>
              </a>
            </span>
          </p>
        </div>
        <img width="0" height="0" src="http://mishler.net/aggbug.ashx?id=754bd904-454a-478e-8b34-fe2b6e30608c" />
      </body>
      <title>How to determine where a provider is configured</title>
      <guid isPermaLink="false">http://mishler.net/PermaLink,guid,754bd904-454a-478e-8b34-fe2b6e30608c.aspx</guid>
      <link>http://mishler.net/2006/04/27/HowToDetermineWhereAProviderIsConfigured.aspx</link>
      <pubDate>Thu, 27 Apr 2006 12:28:52 GMT</pubDate>
      <description>&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;In an Asp.Net application, if you
check the properties of the various Asp.Net providers at runtime, you will get a value
that is something of a hybrid between default and custom settings. Similarly, if you
check a property such as &lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;ConfigurationManager.ConnectionStrings(“LocalSqlServer”).ConnectionString&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;,
you will get a value that may originate in web.config or result from a default setting.&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;b&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;Why is this?&lt;/span&gt;&lt;/b&gt;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;When an Asp.Net 2.0 application
is loaded, the attributes (and behavior) of the various Asp.Net providers (membership,
roleManager, profile and others) are retrieved from sections in machine.config (C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIG\machine.config.)&amp;nbsp;
If the web application includes a web.config file, the configuration sections contained
therein may supplement or override the default behavior.&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;b&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial"&gt;So how do you programmatically
determine if a provider is getting its configuration from the default (machine.config)
file or from an application-specific (web.config) file? &lt;/span&gt;&lt;/b&gt;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;I recently had to deal with this
issue in testing for various potential user problems with the &lt;a title=http://www.qualitydata.com/products/aspnet-membership/default.aspx href="http://www.qualitydata.com/products/aspnet-membership/default.aspx"&gt;&lt;font color=#800080&gt;Membership
Manager Control&lt;/font&gt;&lt;/a&gt;.&amp;nbsp; I was simulating a fairly common scenario where
users might configure their AspNetSqlMembershipProvider to store passwords in an encrypted
format but forget to provide a machineKey section.&amp;nbsp; The machineKey section defines
how to encrypt/decrypt various types of information and, if not defined in web.config,
will produce autogenerated values. Anyone who has tried to go with an encrypted rather
than hashed passwordFormat will have undoubtedly encountered the following message
when they attempt to run the web application:&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN-LEFT: 0.5in"&gt;
&lt;i&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;You must specify a non-autogenerated
machine key to store passwords in the encrypted format. Either specify a different
passwordFormat, or change the machineKey configuration to use a non-autogenerated
decryption key.&lt;/span&gt;&lt;/i&gt;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;This exception is thrown by the
AspNetSQLMembershipProvider to force the web application developer to provide a machineKey
section in web.config. &amp;nbsp;This requirement is well documented and several excellent
resources are available on the Internet to help you generate the elements needed to
create your own custom machineKey configuration section.&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;So in my situation, I wanted to
prevent users from changing an individual member’s passwordFormat to Encrypted if
the machineKey was not specified in web.config. I would need a way to determine this
at runtime.&amp;nbsp;&amp;nbsp;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;Well, it’s easy enough to get a
strongly typed MachineKeySection object. The following VB.Net method illustrates how
to get an instance of the machineKeySection class for the current web project:&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;Public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;Shared&lt;/span&gt; &lt;span style="COLOR: blue"&gt;Function&lt;/span&gt; GetMachineKeySection() &lt;span style="COLOR: blue"&gt;As&lt;/span&gt; System.Web.Configuration.MachineKeySection&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&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: blue"&gt;Static&lt;/span&gt; section &lt;span style="COLOR: blue"&gt;As&lt;/span&gt; MachineKeySection&lt;br&gt;
&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&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: blue"&gt;If&lt;/span&gt; section &lt;span style="COLOR: blue"&gt;Is&lt;/span&gt; &lt;span style="COLOR: blue"&gt;Nothing&lt;/span&gt; &lt;span style="COLOR: blue"&gt;Then&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&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;
section = &lt;span style="COLOR: blue"&gt;CType&lt;/span&gt;(System.Web.Configuration.WebConfigurationManager.GetSection(&lt;span style="COLOR: maroon"&gt;"system.web/machineKey"&lt;/span&gt;),
MachineKeySection)&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&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: blue"&gt;End&lt;/span&gt; &lt;span style="COLOR: blue"&gt;If&lt;br&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&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: blue"&gt;Return&lt;/span&gt; section&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;End&lt;/span&gt; &lt;span style="COLOR: blue"&gt;Function&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;(Note that &lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: maroon; FONT-FAMILY: 'Courier New'"&gt;"system.web/machineKey"&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt; is
case sensitive)&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;And when you check the resulting
instance, you will get information in fields such as decryption, decryptionKey, validation
and validationKey – whether or not a machineKey section exists in web.config.&amp;nbsp; &lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;b&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;/span&gt;&lt;/b&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;b&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;So how can you programmatically
tell if machineKey contains a non-autogenerated decryption key?&lt;/span&gt;&lt;/b&gt;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;The &lt;em&gt;ElementInformation&lt;/em&gt; class
is typically available as a property of sections such as machineKey and can tell you
if a particular element is a collection, if it can be modified and even the line number
where it is defined in its configuration file. And, of course, Microsoft gives us
the IsPresent property which tells us whether or not the element actually exists in
the configuration file. ElementInformation.IsPresent returns a Boolean and is easy
to use as shown in the VB.Net method listed below.&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;Public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;Shared&lt;/span&gt; &lt;span style="COLOR: blue"&gt;Function&lt;/span&gt; HaveMachineKey() &lt;span style="COLOR: blue"&gt;As&lt;/span&gt; &lt;span style="COLOR: blue"&gt;Boolean&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&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: blue"&gt;Dim&lt;/span&gt; section&lt;span style="COLOR: blue"&gt; As&lt;/span&gt; MachineKeySection
= GetMachineKeySection() ' see above &lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&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: blue"&gt;If&lt;/span&gt; &lt;span style="COLOR: blue"&gt;Not&lt;/span&gt; section&lt;span style="COLOR: blue"&gt; Is&lt;/span&gt; &lt;span style="COLOR: blue"&gt;Nothing&lt;/span&gt; &lt;span style="COLOR: blue"&gt;Then&lt;/span&gt;&amp;nbsp;&lt;br&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;&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;section.ElementInformation.IsPresent&lt;br&gt;
&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&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;font color=#0000ff&gt;End
If&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;End&lt;/span&gt; &lt;span style="COLOR: blue"&gt;Function&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;The model for strongly typed configuration
classes has been around since .Net 1.0 and is available for WinForms as well as WebForms
applications. Custom configuration classes are relatively easy to create and provide
a big step up from INI files. &amp;nbsp;In the 2.0 .Net Framework, configuration classes
are even easier to create and provide lots of great new capabilities. This ability
to inherit and override configuration settings does a great job in supporting the
provider model and features such as the &lt;strong&gt;ElementInformation&lt;/strong&gt; class
give the programmer all the information he/she needs to determine the source of any
particular configuration section.&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;div&gt;
&lt;p class=MsoAutoSig&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;Brian Mishler&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoAutoSig&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;a title=http://www.qualitydata.com/ href="http://www.qualitydata.com/"&gt;&lt;font color=#800080&gt;http://www.qualitydata.com&lt;/font&gt;&lt;/a&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;img width="0" height="0" src="http://mishler.net/aggbug.ashx?id=754bd904-454a-478e-8b34-fe2b6e30608c" /&gt;</description>
      <comments>http://mishler.net/CommentView,guid,754bd904-454a-478e-8b34-fe2b6e30608c.aspx</comments>
      <category>.Net</category>
      <category>Asp.Net</category>
      <category>Asp.Net Providers</category>
    </item>
    <item>
      <trackback:ping>http://mishler.net/Trackback.aspx?guid=b140abd4-6f9e-43e5-8ec3-8e5f19c95ea7</trackback:ping>
      <pingback:server>http://mishler.net/pingback.aspx</pingback:server>
      <pingback:target>http://mishler.net/PermaLink,guid,b140abd4-6f9e-43e5-8ec3-8e5f19c95ea7.aspx</pingback:target>
      <dc:creator>Brian Mishler</dc:creator>
      <wfw:comment>http://mishler.net/CommentView,guid,b140abd4-6f9e-43e5-8ec3-8e5f19c95ea7.aspx</wfw:comment>
      <wfw:commentRss>http://mishler.net/SyndicationService.asmx/GetEntryCommentsRss?guid=b140abd4-6f9e-43e5-8ec3-8e5f19c95ea7</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <div class="Section1">
          <p class="MsoNormal">
            <span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">This is one of those “..note to
self” blogs to document for future reference the meaning of the exception message: </span>
          </p>
          <p class="MsoNormal">
            <i>Format of the initialization string does not conform to specification starting
at index 0</i>
          </p>
          <p class="MsoNormal">
            <span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">To me this actually means:</span>
          </p>
          <p class="MsoNormal">
            <i>
              <span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">When the provider is being initialized
with a collection of key/value pairs, the string that defines those key/value pairs
is not properly formatted.</span>
            </i>
          </p>
          <p class="MsoNormal">
            <span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">Perhaps that would be obvious to
most but in my case, the exception would be difficult to track down in the field since
a provider to my provider was actually throwing the exception.  In particular,
my provider (AspNetSqlMembershipProvider) had a properly configured ConnectionStringName
attribute but the format of the corresponding connection string (in the web.config
connectionstrings section) was not properly formatted as “data source=…”. (I had gone
with the proverbial </span>
            <span style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: 'Courier New'">connectionString</span>
            <span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">=</span>
            <span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">"<span style="COLOR: blue">Foo</span>"</span>
            <span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"> to
see if/how it would blow.)  </span>
          </p>
          <p class="MsoNormal">
            <span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">In fact, it was the SqlClient Data
Provider that was originating the exception, at least in my case. </span>
          </p>
          <p class="MsoNormal">
            <span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">I post this here so that if I get
“oldTimers” or if anyone else suffers from the exception, it may help offer a clue.</span>
          </p>
          <p class="MsoNormal">
            <span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">Brian Mishler</span>
          </p>
          <div>
            <p class="MsoAutoSig">
              <span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
                <a href="http://www.qualitydata.com/">http://www.qualitydata.com</a>
              </span>
            </p>
          </div>
          <p class="MsoNormal">
 
</p>
          <p class="MsoNormal">
 
</p>
        </div>
        <img width="0" height="0" src="http://mishler.net/aggbug.ashx?id=b140abd4-6f9e-43e5-8ec3-8e5f19c95ea7" />
      </body>
      <title>Translated Configuration Exception Message, part 1</title>
      <guid isPermaLink="false">http://mishler.net/PermaLink,guid,b140abd4-6f9e-43e5-8ec3-8e5f19c95ea7.aspx</guid>
      <link>http://mishler.net/2006/04/18/TranslatedConfigurationExceptionMessagePart1.aspx</link>
      <pubDate>Tue, 18 Apr 2006 21:56:21 GMT</pubDate>
      <description>&lt;div class=Section1&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;This is one of those “..note to
self” blogs to document for future reference the meaning of the exception message: &lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;i&gt;Format of the initialization string does not conform to specification starting
at index 0&lt;/i&gt;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;To me this actually means:&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;i&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;When the provider is being initialized
with a collection of key/value pairs, the string that defines those key/value pairs
is not properly formatted.&lt;/span&gt;&lt;/i&gt;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;Perhaps that would be obvious to
most but in my case, the exception would be difficult to track down in the field since
a provider to my provider was actually throwing the exception. &amp;nbsp;In particular,
my provider (AspNetSqlMembershipProvider) had a properly configured ConnectionStringName
attribute but the format of the corresponding connection string (in the web.config
connectionstrings section) was not properly formatted as “data source=…”. (I had gone
with the proverbial &lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: 'Courier New'"&gt;connectionString&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;=&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;"&lt;span style="COLOR: blue"&gt;Foo&lt;/span&gt;"&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt; to
see if/how it would blow.)&amp;nbsp; &lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;In fact, it was the SqlClient Data
Provider that was originating the exception, at least in my case. &lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;I post this here so that if I get
“oldTimers” or if anyone else suffers from the exception, it may help offer a clue.&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;Brian Mishler&lt;/span&gt;
&lt;/p&gt;
&lt;div&gt;
&lt;p class=MsoAutoSig&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;a href="http://www.qualitydata.com/"&gt;http://www.qualitydata.com&lt;/a&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;p class=MsoNormal&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;/div&gt;
&lt;img width="0" height="0" src="http://mishler.net/aggbug.ashx?id=b140abd4-6f9e-43e5-8ec3-8e5f19c95ea7" /&gt;</description>
      <comments>http://mishler.net/CommentView,guid,b140abd4-6f9e-43e5-8ec3-8e5f19c95ea7.aspx</comments>
      <category>Asp.Net</category>
    </item>
    <item>
      <trackback:ping>http://mishler.net/Trackback.aspx?guid=d007f698-1c2f-467b-b765-b9da65e7f830</trackback:ping>
      <pingback:server>http://mishler.net/pingback.aspx</pingback:server>
      <pingback:target>http://mishler.net/PermaLink,guid,d007f698-1c2f-467b-b765-b9da65e7f830.aspx</pingback:target>
      <dc:creator>Brian Mishler</dc:creator>
      <wfw:comment>http://mishler.net/CommentView,guid,d007f698-1c2f-467b-b765-b9da65e7f830.aspx</wfw:comment>
      <wfw:commentRss>http://mishler.net/SyndicationService.asmx/GetEntryCommentsRss?guid=d007f698-1c2f-467b-b765-b9da65e7f830</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <div class="Section1">
          <p class="MsoNormal">
            <span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">In an earlier blog, I mentioned
how through the use of Dynamic MasterPages, I could have my web site change its format
based on some arbitrary condition such as the browser type. Here, I have assembled
an example to illustrate Dynamic MasterPages in action. </span>
          </p>
          <p class="MsoNormal">
            <span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
            </span> 
</p>
          <p class="MsoNormal">
            <span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">For this sample, I have created
a single web form that contains our page content. This form (childPage.aspx) gets
its layout from a master page (masterpage1.master) but when a particular condition
is encountered (query parameter “foo” provided), the child will use the layout from
a different master page (masterpage2.master).</span>
          </p>
          <p class="MsoNormal">
            <span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
            </span> 
</p>
          <p class="MsoNormal">
            <span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">Since we might have dozens of pages
that need to dynamically change their layout, I have created a class called “WebFormBase”
that inherits from System.Web.UI.Form and as I add each new web form, I will have
it inherit from my custom base class rather than from the default System.Web.UI.Form.
Now when I add code into “WebFormBase”, my child form (and any other forms that derive
from “WebFormBase”) will enjoy that code.</span>
          </p>
          <p class="MsoNormal">
            <span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">This is a good practice, especially
in large web sites, for many obvious reasons.</span>
          </p>
          <p class="MsoNormal">
            <span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
            </span> 
</p>
          <p class="MsoNormal">
            <span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">To load our “childPage” with different
query parameters, I created “default.aspx” with two hyperlinks. </span>
          </p>
          <ol style="MARGIN-TOP: 0in" type="1">
            <li class="MsoNormal">
              <span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">The first hyperlink loads “childPage.aspx”
with no query parameters.</span>
            </li>
            <li class="MsoNormal">
              <span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">The second hyperlink loads “childPage.aspx”
with the query parameter, “foo”.</span>
            </li>
          </ol>
          <p class="MsoNormal">
            <span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
            </span> 
</p>
          <p class="MsoNormal">
            <span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">This figure illustrates how the
same child page looks when different (dynamic) master pages are applied:</span>
          </p>
          <p class="MsoNormal">
            <span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
            </span> 
</p>
          <p class="MsoNormal">
            <span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
              <img height="421" src="http://brian.mishler.net/content/binary/image001123.gif" width="400" />
            </span>
          </p>
          <p class="MsoNormal">
            <span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
            </span> 
</p>
          <p class="MsoNormal">
            <span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">Here is my custom base class, WebFormBase,
into which I have added a single event handler to check for the “foo” querystring
parameter.</span>
          </p>
          <p class="MsoNormal">
            <span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">public</span>
            <span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">
              <span style="COLOR: blue">class</span>
              <span style="COLOR: teal">WebFormBase</span> :
System.Web.UI.<span style="COLOR: teal">Page</span></span>
          </p>
          <p class="MsoNormal">
            <span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">{</span>
          </p>
          <p class="MsoNormal">
            <span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">    <span style="COLOR: blue">protected</span><span style="COLOR: blue">override</span><span style="COLOR: blue">void</span> OnPreInit(<span style="COLOR: teal">EventArgs</span> e)</span>
          </p>
          <p class="MsoNormal">
            <span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">    {</span>
          </p>
          <p class="MsoNormal">
            <span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">        <span style="COLOR: blue">base</span>.OnPreInit(e);</span>
          </p>
          <p class="MsoNormal">
            <span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">        <span style="COLOR: blue">if</span> (Request.QueryString.Get(<span style="COLOR: maroon">"foo"</span>)
== <span style="COLOR: blue">null</span>){</span>
          </p>
          <p class="MsoNormal">
            <span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">            <span style="COLOR: blue">this</span>.MasterPageFile=<span style="COLOR: maroon">"~/MasterPage1.master"</span>;</span>
          </p>
          <p class="MsoNormal">
            <span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">       
}</span>
          </p>
          <p class="MsoNormal">
            <span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">        <span style="COLOR: blue">else</span>{</span>
          </p>
          <p class="MsoNormal">
            <span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">            <span style="COLOR: blue">this</span>.MasterPageFile=<span style="COLOR: maroon">"~/MasterPage2.master"</span>;</span>
          </p>
          <p class="MsoNormal">
            <span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">       
}</span>
          </p>
          <p class="MsoNormal">
            <span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">    }</span>
          </p>
          <p class="MsoNormal">
            <span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">}</span>
          </p>
          <p class="MsoNormal">
            <span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
            </span> 
</p>
          <p class="MsoNormal">
            <span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">The following code is for “ChildPage.aspx”,
the web page whose layout is controlled by the two master pages. Notice that the MasterPageFile
attribute is initially defined as “MasterPage1.master” and also that <b>Inherits=”WebFormBase”</b> causes
the web form to inherit from our custom class rather than the built in webforms base
class. </span>
          </p>
          <p class="MsoNormal">
            <span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
            </span> 
</p>
          <p class="MsoNormal">
            <span style="FONT-SIZE: 10pt; BACKGROUND: yellow; FONT-FAMILY: 'Courier New'">&lt;%</span>
            <span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">@</span>
            <span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">
              <span style="COLOR: maroon">Page</span>
              <span style="COLOR: red">Language</span>
              <span style="COLOR: blue">="C#"</span>
              <span style="COLOR: red">MasterPageFile</span>
              <span style="COLOR: blue">="~/MasterPage1.master"</span>
              <span style="COLOR: red">Title</span>
              <span style="COLOR: blue">="Variable
Page"</span>
              <span style="COLOR: red">Inherits</span>
              <span style="COLOR: blue">="WebFormBase"</span>
              <span style="BACKGROUND: yellow">%&gt;</span>
            </span>
          </p>
          <p class="MsoNormal">
            <span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">&lt;</span>
            <span style="FONT-SIZE: 10pt; COLOR: maroon; FONT-FAMILY: 'Courier New'">asp</span>
            <span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">:</span>
            <span style="FONT-SIZE: 10pt; COLOR: maroon; FONT-FAMILY: 'Courier New'">Content</span>
            <span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">
              <span style="COLOR: red">ID</span>
              <span style="COLOR: blue">="foo"</span>
              <span style="COLOR: red">ContentPlaceHolderID</span>
              <span style="COLOR: blue">="ContentPlaceHolder1"</span>
              <span style="COLOR: red">runat</span>
              <span style="COLOR: blue">="server"&gt;</span>
            </span>
          </p>
          <p class="MsoNormal" style="MARGIN-LEFT: 0.5in">
            <span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">&lt;</span>
            <span style="FONT-SIZE: 10pt; COLOR: maroon; FONT-FAMILY: 'Courier New'">div</span>
            <span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">
              <span style="COLOR: red">style</span>
              <span style="COLOR: blue">="background-color:White;padding:10px
10px 10px 10px"&gt;<br /></span>This is the content that is embedded in the child page. Depending on the dynamically
selected master page, my surroundings may differ.<br /><span style="COLOR: blue">&lt;/</span><span style="COLOR: maroon">div</span><span style="COLOR: blue">&gt;</span></span>
          </p>
          <p class="MsoNormal">
            <span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">&lt;/</span>
            <span style="FONT-SIZE: 10pt; COLOR: maroon; FONT-FAMILY: 'Courier New'">asp</span>
            <span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">:</span>
            <span style="FONT-SIZE: 10pt; COLOR: maroon; FONT-FAMILY: 'Courier New'">Content</span>
            <span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">&gt;</span>
          </p>
          <p class="MsoNormal">
            <span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
            </span> 
</p>
          <p class="MsoNormal">
            <span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">One final note is that since I have
defined that <b>ContentPlaceHolderID=”ContentPlaceHolder1”</b>, the alternate master
page must have a content place holder named “ContentPlaceHolder1” or the page will
erupt at runtime.</span>
          </p>
          <p class="MsoNormal">
            <span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
            </span> 
</p>
          <p class="MsoNormal">
            <span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">Feel free to download and run the
sample web site which is available as a Zip file near the bottom of this post. As
always, any comments and opinions are appreciated.</span>
          </p>
          <p class="MsoNormal">
            <span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
            </span> 
</p>
          <div>
            <p class="MsoAutoSig">
              <span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">Brian Mishler</span>
            </p>
            <p class="MsoAutoSig">
              <span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
                <a href="http://www.qualitydata.com/">http://www.qualitydata.com</a>
              </span>
            </p>
          </div>
          <p class="MsoNormal">
 
</p>
          <p class="MsoNormal">
 
</p>
        </div>
        <p>
Download: <a href="http://brian.mishler.net/content/binary/DynamicMasterPageSample.zip">DynamicMasterPageSample.zip</a><br /></p>
        <a href="http://brian.mishler.net/content/binary/DynamicMasterPageSample.zip">DynamicMasterPageSample.zip
(2.51 KB)</a>
        <img width="0" height="0" src="http://mishler.net/aggbug.ashx?id=d007f698-1c2f-467b-b765-b9da65e7f830" />
      </body>
      <title>Dynamic MasterPages, Part 2</title>
      <guid isPermaLink="false">http://mishler.net/PermaLink,guid,d007f698-1c2f-467b-b765-b9da65e7f830.aspx</guid>
      <link>http://mishler.net/2006/04/10/DynamicMasterPagesPart2.aspx</link>
      <pubDate>Mon, 10 Apr 2006 04:18:29 GMT</pubDate>
      <description>&lt;div class=Section1&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;In an earlier blog, I mentioned
how through the use of Dynamic MasterPages, I could have my web site change its format
based on some arbitrary condition such as the browser type. Here, I have assembled
an example to illustrate Dynamic MasterPages in action. &lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;For this sample, I have created
a single web form that contains our page content. This form (childPage.aspx) gets
its layout from a master page (masterpage1.master) but when a particular condition
is encountered (query parameter “foo” provided), the child will use the layout from
a different master page (masterpage2.master).&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;Since we might have dozens of pages
that need to dynamically change their layout, I have created a class called “WebFormBase”
that inherits from System.Web.UI.Form and as I add each new web form, I will have
it inherit from my custom base class rather than from the default System.Web.UI.Form.
Now when I add code into “WebFormBase”, my child form (and any other forms that derive
from “WebFormBase”) will enjoy that code.&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;This is a good practice, especially
in large web sites, for many obvious reasons.&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;To load our “childPage” with different
query parameters, I created “default.aspx” with two hyperlinks. &lt;/span&gt;
&lt;/p&gt;
&lt;ol style="MARGIN-TOP: 0in" type=1&gt;
&lt;li class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;The first hyperlink loads “childPage.aspx”
with no query parameters.&lt;/span&gt; 
&lt;li class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;The second hyperlink loads “childPage.aspx”
with the query parameter, “foo”.&lt;/span&gt; 
&lt;/li&gt;
&lt;/ol&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;This figure illustrates how the
same child page looks when different (dynamic) master pages are applied:&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;img height=421 src="http://brian.mishler.net/content/binary/image001123.gif" width=400&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;Here is my custom base class, WebFormBase,
into which I have added a single event handler to check for the “foo” querystring
parameter.&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;public&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt; &lt;span style="COLOR: blue"&gt;class&lt;/span&gt; &lt;span style="COLOR: teal"&gt;WebFormBase&lt;/span&gt; :
System.Web.UI.&lt;span style="COLOR: teal"&gt;Page&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;{&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;protected&lt;/span&gt; &lt;span style="COLOR: blue"&gt;override&lt;/span&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; OnPreInit(&lt;span style="COLOR: teal"&gt;EventArgs&lt;/span&gt; e)&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;base&lt;/span&gt;.OnPreInit(e);&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (Request.QueryString.Get(&lt;span style="COLOR: maroon"&gt;"foo"&lt;/span&gt;)
== &lt;span style="COLOR: blue"&gt;null&lt;/span&gt;){&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&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: blue"&gt;this&lt;/span&gt;.MasterPageFile=&lt;span style="COLOR: maroon"&gt;"~/MasterPage1.master"&lt;/span&gt;;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;else&lt;/span&gt;{&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&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: blue"&gt;this&lt;/span&gt;.MasterPageFile=&lt;span style="COLOR: maroon"&gt;"~/MasterPage2.master"&lt;/span&gt;;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt;}&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;The following code is for “ChildPage.aspx”,
the web page whose layout is controlled by the two master pages. Notice that the MasterPageFile
attribute is initially defined as “MasterPage1.master” and also that &lt;b&gt;Inherits=”WebFormBase”&lt;/b&gt; causes
the web form to inherit from our custom class rather than the built in webforms base
class. &lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; BACKGROUND: yellow; FONT-FAMILY: 'Courier New'"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;@&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt; &lt;span style="COLOR: maroon"&gt;Page&lt;/span&gt; &lt;span style="COLOR: red"&gt;Language&lt;/span&gt;&lt;span style="COLOR: blue"&gt;="C#"&lt;/span&gt; &lt;span style="COLOR: red"&gt;MasterPageFile&lt;/span&gt;&lt;span style="COLOR: blue"&gt;="~/MasterPage1.master"&lt;/span&gt; &lt;span style="COLOR: red"&gt;Title&lt;/span&gt;&lt;span style="COLOR: blue"&gt;="Variable
Page"&lt;/span&gt; &lt;span style="COLOR: red"&gt;Inherits&lt;/span&gt;&lt;span style="COLOR: blue"&gt;="WebFormBase"&lt;/span&gt; &lt;span style="BACKGROUND: yellow"&gt;%&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;lt;&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: maroon; FONT-FAMILY: 'Courier New'"&gt;asp&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;:&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: maroon; FONT-FAMILY: 'Courier New'"&gt;Content&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt; &lt;span style="COLOR: red"&gt;ID&lt;/span&gt;&lt;span style="COLOR: blue"&gt;="foo"&lt;/span&gt; &lt;span style="COLOR: red"&gt;ContentPlaceHolderID&lt;/span&gt;&lt;span style="COLOR: blue"&gt;="ContentPlaceHolder1"&lt;/span&gt; &lt;span style="COLOR: red"&gt;runat&lt;/span&gt;&lt;span style="COLOR: blue"&gt;="server"&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN-LEFT: 0.5in"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;lt;&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: maroon; FONT-FAMILY: 'Courier New'"&gt;div&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"&gt; &lt;span style="COLOR: red"&gt;style&lt;/span&gt;&lt;span style="COLOR: blue"&gt;="background-color:White;padding:10px
10px 10px 10px"&amp;gt;&lt;br&gt;
&lt;/span&gt;This is the content that is embedded in the child page. Depending on the dynamically
selected master page, my surroundings may differ.&lt;br&gt;
&lt;span style="COLOR: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: maroon"&gt;div&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: maroon; FONT-FAMILY: 'Courier New'"&gt;asp&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;:&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: maroon; FONT-FAMILY: 'Courier New'"&gt;Content&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;One final note is that since I have
defined that &lt;b&gt;ContentPlaceHolderID=”ContentPlaceHolder1”&lt;/b&gt;, the alternate master
page must have a content place holder named “ContentPlaceHolder1” or the page will
erupt at runtime.&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;Feel free to download and run the
sample web site which is available as a Zip file near the bottom of this post. As
always, any comments and opinions are appreciated.&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;div&gt;
&lt;p class=MsoAutoSig&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;Brian Mishler&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoAutoSig&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;a href="http://www.qualitydata.com/"&gt;http://www.qualitydata.com&lt;/a&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;p class=MsoNormal&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;
Download: &lt;a href="http://brian.mishler.net/content/binary/DynamicMasterPageSample.zip"&gt;DynamicMasterPageSample.zip&lt;/a&gt;
&lt;br&gt;
&lt;/p&gt;
&lt;a href="http://brian.mishler.net/content/binary/DynamicMasterPageSample.zip"&gt;DynamicMasterPageSample.zip
(2.51 KB)&lt;/a&gt;&lt;img width="0" height="0" src="http://mishler.net/aggbug.ashx?id=d007f698-1c2f-467b-b765-b9da65e7f830" /&gt;</description>
      <comments>http://mishler.net/CommentView,guid,d007f698-1c2f-467b-b765-b9da65e7f830.aspx</comments>
      <category>Asp.Net</category>
    </item>
    <item>
      <trackback:ping>http://mishler.net/Trackback.aspx?guid=89850ecb-7936-4d4c-a9dc-61178a3f3e45</trackback:ping>
      <pingback:server>http://mishler.net/pingback.aspx</pingback:server>
      <pingback:target>http://mishler.net/PermaLink,guid,89850ecb-7936-4d4c-a9dc-61178a3f3e45.aspx</pingback:target>
      <dc:creator>Brian Mishler</dc:creator>
      <wfw:comment>http://mishler.net/CommentView,guid,89850ecb-7936-4d4c-a9dc-61178a3f3e45.aspx</wfw:comment>
      <wfw:commentRss>http://mishler.net/SyndicationService.asmx/GetEntryCommentsRss?guid=89850ecb-7936-4d4c-a9dc-61178a3f3e45</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <div class="Section1">
          <p class="MsoNormal">
            <span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">So in <a href="http://brian.mishler.net/PermaLink,guid,dafdd9ae-5d5b-40e2-8c33-1ec0a119efb5.aspx">another
blog</a>, I mentioned a technique where I could hide obsolete content throughout my
site by simply placing ContentPlaceHolders into hidden panels in the MasterPage.  In
that context, this practice might be a temporary fix pending a visit to each page
in the web site.</span>
          </p>
          <p class="MsoNormal">
            <span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">Since our business involves a lot
of mobility and we invite customers to visit our web site from their pocket pc, I’ve
been thinking that this technique of "hiding" content placeholders might offer a better
way to create a Pocket PC friendly user experience.  </span>
          </p>
          <p class="MsoNormal">
            <span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">Currently, I substitute the
CSS file or even redirect the user to a special section of my web site whenever I
detect they are using Pocket IE. You can see this in action if you visit <a href="http://www.pocketforms.net/">http://www.pocketforms.net</a> (first
in your browser then from your pocket pc.) </span>
          </p>
          <p class="MsoNormal">
            <span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">With Dynamic MasterPages, I can
programmatically select a specific master page based on the requestor's browser
type.  The pocket pc (or smartphone) master page, for example, can reference
a style sheet (.CSS file) which is appropriate for the device and also hide superfluous
ContentPlaceHolders such as banners and advertising.  This approach works much
better than a pure CSS approach since hidden content is omitted server-side and never
sent to the client.</span>
          </p>
          <p class="MsoNormal">
            <span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">The following code was inspired
by <a href="blogs.msdn.com/keiths">Keith Smith's</a> presentation at the <a href="http://www.onetug.org/">Orlando
.Net User Group</a> and can be used to programmatically switch to the Pocket PC friendly
master page when a "Windows CE" (pocket pc) browser is detected.  In the following
code, the master page, pocketpc.master, changes the layout, hides some of the content
and references a CSS file with fonts and layout which are better suited for the smaller
form factor of a pocket pc.</span>
          </p>
          <p>
            <span style="FONT-SIZE: 10pt; COLOR: blue">protected</span>
            <span style="FONT-SIZE: 10pt">
              <span style="COLOR: blue">void</span> Page
PreInit(<span style="COLOR: blue">object</span> sender, <span style="COLOR: teal">EventArgs</span> e)
{<br /><span style="COLOR: blue">    if</span>(Request.Browser.Browser.ToLower.Contains(<span style="COLOR: maroon">"windows
ce")){<br /></span><span style="COLOR: blue">        this</span><span style="COLOR: maroon">.MasterPageFile
= "~/pocketpc.master";<br />
        }<br /></span><span style="COLOR: blue">        else</span> {<br /><span style="COLOR: blue">        this</span>.MasterPageFile
= <span style="COLOR: maroon">"~/MasterPage.master"</span>;<br />
    }<br />
}</span>
          </p>
          <p>
            <span style="FONT-SIZE: 10pt">In VB.Net, it looks like this:</span>
          </p>
          <p>
            <span style="FONT-SIZE: 10pt; COLOR: blue">Protected</span>
            <span style="FONT-SIZE: 10pt">
              <span style="COLOR: blue">Sub</span> Page
PreInit(<span style="COLOR: blue">ByVal</span> sender <span style="COLOR: blue">As</span><span style="COLOR: blue">Object</span>, <span style="COLOR: blue">ByVal</span> e <span style="COLOR: blue">As</span> System.EventArgs) <span style="COLOR: blue">Handles</span><span style="COLOR: blue">Me</span>.PreInit<br /><span style="COLOR: blue">    If</span> Request.Browser.Browser.ToLower.Contains(<span style="COLOR: maroon">"windows
ce"</span>) <span style="COLOR: blue">Then<br />
        Me</span>.MasterPageFile = <span style="COLOR: maroon">"~\pocketpc.master"<br /></span><span style="COLOR: blue">    Else<br />
        Me</span>.MasterPageFile = <span style="COLOR: maroon">"~\MasterPage.master"<br /></span><span style="COLOR: blue">    End</span><span style="COLOR: blue">If<br />
End</span><span style="COLOR: blue">Sub</span></span>
          </p>
          <p class="MsoNormal">
            <span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">Notice that the opportunity to swap
out the MasterPageFile occurs in the PreInit method which occurs early in the page
lifecycle (before any custom controls are loaded.) This means that the code cannot
be placed into a web custom control (which would be really convenient) but, instead
must be placed into the inline code or code-behind file of each page. </span>
            <br />
            <span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">Rather than adding this code to
each page, this begs for a technique you always hear Carl Franklin, Richard Campbell
and their guests talking about on <a href="http://www.dotnetrocks.com/">.Net
Rocks</a>. That is, to have all your web forms inherit from a custom class rather
than from the default, System.Web.UI.Page. When you add behaviors such as variable
MasterPages to your custom page class, then all of your (derived) web forms will inherit
that behavior as well.  Since each of my pages inherit from a class called “webFormBase”,
I simply added the code into the Page PreInit event within webFormBase and I get automatic
master page switching.</span>
          </p>
          <p class="MsoNormal">
            <span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">Watch for another blog on this subject
for a generic sample of this in action.</span>
          </p>
          <p class="MsoNormal">
            <span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
            </span> 
</p>
          <div>
            <p class="MsoAutoSig">
              <span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">Brian Mishler</span>
            </p>
            <p class="MsoAutoSig">
              <span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
                <a href="http://www.qualitydata.com/">http://www.qualitydata.com</a>
              </span>
            </p>
          </div>
          <p class="MsoNormal">
 
</p>
          <p class="MsoNormal">
 
</p>
        </div>
        <img width="0" height="0" src="http://mishler.net/aggbug.ashx?id=89850ecb-7936-4d4c-a9dc-61178a3f3e45" />
      </body>
      <title>Dynamic Master Pages</title>
      <guid isPermaLink="false">http://mishler.net/PermaLink,guid,89850ecb-7936-4d4c-a9dc-61178a3f3e45.aspx</guid>
      <link>http://mishler.net/2006/04/10/DynamicMasterPages.aspx</link>
      <pubDate>Mon, 10 Apr 2006 01:21:53 GMT</pubDate>
      <description>&lt;div class=Section1&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;So in &lt;a href="http://brian.mishler.net/PermaLink,guid,dafdd9ae-5d5b-40e2-8c33-1ec0a119efb5.aspx"&gt;another
blog&lt;/a&gt;, I mentioned a technique where I could hide obsolete content throughout my
site by simply placing ContentPlaceHolders into hidden panels in the MasterPage. &amp;nbsp;In
that context, this practice might be a temporary fix pending a visit to each page
in the web site.&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;Since our business involves a lot
of mobility and we invite customers to visit our web site from their pocket pc, I’ve
been thinking that this technique of "hiding" content placeholders might offer a better
way to create a Pocket PC friendly user experience.&amp;nbsp; &lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;Currently, I&amp;nbsp;substitute the
CSS file or even redirect the user to a special section of my web site whenever I
detect they are using Pocket IE. You can see this in action if you visit &lt;a href="http://www.pocketforms.net/"&gt;http://www.pocketforms.net&lt;/a&gt; (first
in your browser then from your pocket pc.) &lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;With Dynamic MasterPages, I can
programmatically select a specific master page based on the&amp;nbsp;requestor's browser
type.&amp;nbsp; The pocket pc (or smartphone) master page, for example, can reference
a style sheet (.CSS file) which is appropriate for the device and also hide superfluous
ContentPlaceHolders such as banners and advertising.&amp;nbsp; This approach works much
better than a pure CSS approach since hidden content is omitted server-side and never
sent to the client.&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;The following code was inspired
by &lt;a href="blogs.msdn.com/keiths"&gt;Keith Smith's&lt;/a&gt; presentation at the &lt;a href="http://www.onetug.org/"&gt;Orlando
.Net User Group&lt;/a&gt; and can be used to programmatically switch to the Pocket PC friendly
master page when a "Windows CE" (pocket pc) browser is detected.&amp;nbsp; In the following
code, the master page, pocketpc.master, changes the layout, hides some of the content
and references a CSS file with fonts and layout which are better suited for the smaller
form factor of a pocket pc.&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: blue"&gt;protected&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt"&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; Page
PreInit(&lt;span style="COLOR: blue"&gt;object&lt;/span&gt; sender, &lt;span style="COLOR: teal"&gt;EventArgs&lt;/span&gt; e)
{&lt;br&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if&lt;/span&gt;(Request.Browser.Browser.ToLower.Contains(&lt;span style="COLOR: maroon"&gt;"windows
ce")){&lt;br&gt;
&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; this&lt;/span&gt;&lt;span style="COLOR: maroon"&gt;.MasterPageFile
= "~/pocketpc.master";&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; else&lt;/span&gt; {&lt;br&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; this&lt;/span&gt;.MasterPageFile
= &lt;span style="COLOR: maroon"&gt;"~/MasterPage.master"&lt;/span&gt;;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
}&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 10pt"&gt;In VB.Net, it looks like this:&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: blue"&gt;Protected&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt"&gt; &lt;span style="COLOR: blue"&gt;Sub&lt;/span&gt; Page
PreInit(&lt;span style="COLOR: blue"&gt;ByVal&lt;/span&gt; sender &lt;span style="COLOR: blue"&gt;As&lt;/span&gt; &lt;span style="COLOR: blue"&gt;Object&lt;/span&gt;, &lt;span style="COLOR: blue"&gt;ByVal&lt;/span&gt; e &lt;span style="COLOR: blue"&gt;As&lt;/span&gt; System.EventArgs) &lt;span style="COLOR: blue"&gt;Handles&lt;/span&gt; &lt;span style="COLOR: blue"&gt;Me&lt;/span&gt;.PreInit&lt;br&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; If&lt;/span&gt; Request.Browser.Browser.ToLower.Contains(&lt;span style="COLOR: maroon"&gt;"windows
ce"&lt;/span&gt;) &lt;span style="COLOR: blue"&gt;Then&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Me&lt;/span&gt;.MasterPageFile = &lt;span style="COLOR: maroon"&gt;"~\pocketpc.master"&lt;br&gt;
&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Else&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Me&lt;/span&gt;.MasterPageFile = &lt;span style="COLOR: maroon"&gt;"~\MasterPage.master"&lt;br&gt;
&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; End&lt;/span&gt; &lt;span style="COLOR: blue"&gt;If&lt;br&gt;
End&lt;/span&gt; &lt;span style="COLOR: blue"&gt;Sub&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;Notice that the opportunity to swap
out the MasterPageFile occurs in the PreInit method which occurs early in the page
lifecycle (before any custom controls are loaded.) This means that the code cannot
be placed into a web custom control (which would be really convenient) but, instead
must be placed into the inline code or code-behind file of each page.&amp;nbsp;&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;Rather than adding this code to
each page, this begs for a technique you always hear Carl Franklin, Richard Campbell
and their guests&amp;nbsp;talking about on &lt;a href="http://www.dotnetrocks.com/"&gt;.Net
Rocks&lt;/a&gt;. That is, to have all your web forms inherit from a custom class rather
than from the default, System.Web.UI.Page. When you add behaviors&amp;nbsp;such as&amp;nbsp;variable
MasterPages to your custom page class, then all of your (derived)&amp;nbsp;web forms will&amp;nbsp;inherit
that behavior as well. &amp;nbsp;Since each of my pages inherit from a class called “webFormBase”,
I simply added the code into the Page PreInit event within webFormBase and I get automatic
master page switching.&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;Watch for another blog on this subject
for a generic sample of this in action.&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;div&gt;
&lt;p class=MsoAutoSig&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;Brian Mishler&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoAutoSig&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;a href="http://www.qualitydata.com/"&gt;http://www.qualitydata.com&lt;/a&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;p class=MsoNormal&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;/div&gt;
&lt;img width="0" height="0" src="http://mishler.net/aggbug.ashx?id=89850ecb-7936-4d4c-a9dc-61178a3f3e45" /&gt;</description>
      <comments>http://mishler.net/CommentView,guid,89850ecb-7936-4d4c-a9dc-61178a3f3e45.aspx</comments>
      <category>Asp.Net</category>
    </item>
    <item>
      <trackback:ping>http://mishler.net/Trackback.aspx?guid=dafdd9ae-5d5b-40e2-8c33-1ec0a119efb5</trackback:ping>
      <pingback:server>http://mishler.net/pingback.aspx</pingback:server>
      <pingback:target>http://mishler.net/PermaLink,guid,dafdd9ae-5d5b-40e2-8c33-1ec0a119efb5.aspx</pingback:target>
      <dc:creator>Brian Mishler</dc:creator>
      <wfw:comment>http://mishler.net/CommentView,guid,dafdd9ae-5d5b-40e2-8c33-1ec0a119efb5.aspx</wfw:comment>
      <wfw:commentRss>http://mishler.net/SyndicationService.asmx/GetEntryCommentsRss?guid=dafdd9ae-5d5b-40e2-8c33-1ec0a119efb5</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <div class="Section1">
          <p class="MsoNormal">
            <span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">Last year, I re-designed our corporate
web site to use the MasterPages feature in what was then the Beta version
of Visual Studio 2005. I did not bother to read the documentation (which
is a testament to their ease-of-use) and if I had, I might have discovered how
default template placeholders work.</span>
          </p>
          <p class="MsoNormal">
 
</p>
          <p class="MsoNormal">
            <span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">Like a lot of folks, I created a
Master Page first and then created web forms that "used a selected master page".
When you create a new form in this way, content panels which correspond to each
of the Master Page's ContentPlaceholders are automatically inserted into the page.
The next step is obviously to add a bunch of page-specific content into each panel.
This was very intuitive and for me, my efforts were well rewarded when I later changed
the layout of my master page and everything fell into place.</span>
          </p>
          <p class="MsoNormal">
 
</p>
          <p class="MsoNormal">
            <span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">At last week's Orlando .Net User
Group (ONETUG) meeting here in Orlando, <a href="http://blogs.msdn.com/keiths">Microsoft's
Keith Smith</a> gave a really great presentation on Master Pages and Atlas. He demonstrated
how to add content into the ContentPlaceHolders of the Master Page, then, by simply
omitting the corresponding content panel on a detail page, the (default) content of
the Master Page's ContentPlaceHolder is rendered in its place.</span>
          </p>
          <p class="MsoNormal">
 
</p>
          <p class="MsoNormal">
            <span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">Since I had gotten into the
habit of adding an empty ContentPlaceHolder to the Master Page then updating each
web form with the corresponding content, I might never have realized that the ContentPanel
on each form is optional. A few months ago, in fact, I systematically updated every
one of my web pages with a ContentPanel corresponding to a new ContentPlaceHolder.
Ironically, most of the new content panels received the same user control
which, of course, could have been the default content of my new ContentPanel.</span>
          </p>
          <p class="MsoNormal">
 
</p>
          <p class="MsoNormal">
            <span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">Live and learn!</span>
          </p>
          <p class="MsoNormal">
 
</p>
          <p class="MsoNormal">
            <span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">Going the other way, I had a situation
where I needed to get rid of obsolete Content Panels on my web pages. Each of
my pages included a content panel into which I had placed an image control with a
unique graphic for the page.  When I deleted the corresponding ContentPlaceHolder
from the master page, each of my pages complained that the ContentPanel had an invalid
ContentPlaceHolder attribute. While I would ultimately want to visit each page and
delete that ContentPanel (or recycle it with different content), I was able to instantly
omit the content by restoring the ContentPlaceHolder in my master page and placing
it into a hidden Panel Control.</span>
          </p>
          <p class="MsoNormal">
            <span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
            </span> 
</p>
          <p class="MsoNormal">
            <span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
            </span> 
</p>
          <div>
            <p class="MsoAutoSig">
              <span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">Brian Mishler</span>
            </p>
            <p class="MsoAutoSig">
              <span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
                <a href="http://www.qualitydata.com/">http://www.qualitydata.com</a>
              </span>
            </p>
          </div>
          <p class="MsoNormal">
 
</p>
          <p class="MsoNormal">
 
</p>
        </div>
        <img width="0" height="0" src="http://mishler.net/aggbug.ashx?id=dafdd9ae-5d5b-40e2-8c33-1ec0a119efb5" />
      </body>
      <title>Default ContentPlaceHolder content in Asp.Net MasterPages</title>
      <guid isPermaLink="false">http://mishler.net/PermaLink,guid,dafdd9ae-5d5b-40e2-8c33-1ec0a119efb5.aspx</guid>
      <link>http://mishler.net/2006/04/09/DefaultContentPlaceHolderContentInAspNetMasterPages.aspx</link>
      <pubDate>Sun, 09 Apr 2006 00:00:40 GMT</pubDate>
      <description>&lt;div class=Section1&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;Last year, I re-designed our corporate
web site to use the&amp;nbsp;MasterPages feature in what was&amp;nbsp;then the Beta version
of&amp;nbsp;Visual Studio 2005. I&amp;nbsp;did&amp;nbsp;not bother to read the documentation (which
is a testament to&amp;nbsp;their ease-of-use) and if I had, I might have discovered&amp;nbsp;how
default template placeholders work.&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;Like a lot of folks, I created a
Master Page first and then created web forms&amp;nbsp;that&amp;nbsp;"used a selected master&amp;nbsp;page".
When you create a new form in this way,&amp;nbsp;content panels which correspond to each
of the Master Page's ContentPlaceholders are automatically inserted into the page.
The next step is obviously to add a bunch of page-specific content into each panel.
This was very intuitive and for me, my efforts were well rewarded when I later changed
the layout of my master page and everything fell into place.&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;At last week's Orlando .Net User
Group (ONETUG) meeting here in Orlando, &lt;a href="http://blogs.msdn.com/keiths"&gt;Microsoft's
Keith Smith&lt;/a&gt; gave a really great presentation on Master Pages and Atlas. He demonstrated
how to add content into the ContentPlaceHolders of the Master Page, then, by simply
omitting the corresponding content panel on a detail page, the (default) content of
the Master Page's ContentPlaceHolder is rendered in its place.&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;Since&amp;nbsp;I had gotten into the
habit of adding an empty ContentPlaceHolder to the Master Page then updating each
web form with the corresponding content, I might never have realized that the ContentPanel
on each form is optional. A few months ago, in fact, I systematically updated every
one of my web pages with a ContentPanel corresponding to a new ContentPlaceHolder.
Ironically,&amp;nbsp;most of the new content panels received&amp;nbsp;the same user control
which, of course, could have been the default content of my new ContentPanel.&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;Live and learn!&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;Going the other way, I had a situation
where I needed to get rid of&amp;nbsp;obsolete Content Panels on my web pages. Each of
my pages included a content panel into which I had placed an image control with a
unique graphic for the page.&amp;nbsp; When I deleted&amp;nbsp;the corresponding ContentPlaceHolder
from the master page, each of my pages complained that the ContentPanel had an invalid
ContentPlaceHolder attribute. While I would ultimately want to visit each page and
delete that ContentPanel (or recycle it with different content), I was able to instantly
omit the content by&amp;nbsp;restoring the ContentPlaceHolder in my master page and&amp;nbsp;placing
it into a hidden Panel Control.&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;div&gt;
&lt;p class=MsoAutoSig&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;Brian Mishler&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoAutoSig&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;a href="http://www.qualitydata.com/"&gt;http://www.qualitydata.com&lt;/a&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;p class=MsoNormal&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;/div&gt;
&lt;img width="0" height="0" src="http://mishler.net/aggbug.ashx?id=dafdd9ae-5d5b-40e2-8c33-1ec0a119efb5" /&gt;</description>
      <comments>http://mishler.net/CommentView,guid,dafdd9ae-5d5b-40e2-8c33-1ec0a119efb5.aspx</comments>
      <category>Asp.Net</category>
    </item>
  </channel>
</rss>