<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>Andrew Hay - asp.net</title>
    <link>http://www.andrewdothay.net/blog/</link>
    <description>Thinking way too long about the subtitle</description>
    <language>en-us</language>
    <copyright>Andrew Hay</copyright>
    <lastBuildDate>Wed, 28 Jan 2009 02:57:42 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.0.7226.0</generator>
    <managingEditor>andrewcameronhay@hotmail.com</managingEditor>
    <webMaster>andrewcameronhay@hotmail.com</webMaster>
    <item>
      <trackback:ping>http://www.andrewdothay.net/blog/Trackback.aspx?guid=b191edc1-c409-4467-978e-ba58adab6d1d</trackback:ping>
      <pingback:server>http://www.andrewdothay.net/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.andrewdothay.net/blog/PermaLink,guid,b191edc1-c409-4467-978e-ba58adab6d1d.aspx</pingback:target>
      <dc:creator>Andrew Hay</dc:creator>
      <wfw:comment>http://www.andrewdothay.net/blog/CommentView,guid,b191edc1-c409-4467-978e-ba58adab6d1d.aspx</wfw:comment>
      <wfw:commentRss>http://www.andrewdothay.net/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=b191edc1-c409-4467-978e-ba58adab6d1d</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
When I've needed to invoke a cache mechanism for data on a web site, I've happily
used the ASP.Net Cache object over the past few years. It's a nice model for storing
a chunk of data under a key until a specific time or for a given duration, providing
the application domain doesn't recycle.
</p>
        <p>
I've even hooked up some systems that resemble a Rube Goldberg apparatus to get the
same features as a job scheduler, but I don't like to talk about them. ASP.Net will
fire an event that you can use when something expires from the cache and therefore
give you the "Cache, Wait, Expire, Do Something, Repeat" model for solving
a job scheduling problem.
</p>
        <p>
.Net 2.0 and up supported the <a href="http://msdn.microsoft.com/en-us/library/system.web.caching.sqlcachedependency.aspx">SqlCacheDependency</a> class.
One of its talents is the ability to expire a cached object when the underlying database
changes. Before this feature was available, you might wire up specific cache expiration
logic in relevant insert, update or delete functions of your app. However, that falls
short when the database is updated outside of the trip wires you set in your own code.
Another application might update that database, or someone might edit the database
through Query Analyzer.
</p>
        <p>
Way back in the day, my team set out to bag the big beast by writing a trigger in
SQL Server that would reach out an edit a text file whenever a specific table was
modified. This event would be observed by the cache dependency object that was good
at watching physical files for changes and ska-doosh! We've got our SQL Server cache
dependency working.
</p>
        <p>
Nowadays, those long, verbose methods aren't required. We've got a set of fancy new
tools, namely, the SqlCacheDependency object. Or so I thought.
</p>
        <p>
Its great that support goes all the way back to SQL Server 7, albeit via a costly
polling mechanism. SQL Server 2005 gave us a direct feedback loop that avoided the
polling system. I've know about this feature, as a concept, since it came out but
only in the past few weeks have I really looked at the code to use it and I'm honestly
a little shocked at the site. 
</p>
        <p>
I was really expecting something akin to the familiar practice of checking the cache
for the existence of the object, and if necessary, repopulation of the cache. It turns
out there's a few more steps, and a little craziness if you want to use LINQ to access
your database. 
</p>
        <p>
I'll always leave the door open and hope that some day I'll learn the super easy way
of doing this, but today, so much of this is in the non-trivial bucket that I'm really
tempted to leave it alone and continue my current caching practices.
</p>
        <p>
A year or more ago, I would reach for the data access block inside the <a href="http://www.codeplex.com/entlib">Enterprise
Library</a> as a default choice. It's a great data access layer and sure beats writing
all that goo on my own. Today, I'll reach for LINQ as my default choice. As I understand
it, Microsoft is touting the Entity Framework as the future of data access, but today,
I'm still sitting contently in the LINQ boat. Who knows what the future holds for
me.
</p>
        <p>
To be fair, the example code in MSDN that shows how to implement the SqlCacheDependency
actually looks pretty good when you're creating your own Command objects. Not much
to talk about there. But I was disappointed when I looked at the LINQ story. Perhaps
LINQ just got out ahead too far from the pack and better things are coming. 
</p>
        <p>
          <a href="http://code.msdn.microsoft.com/linqtosqlcache">One of the cleaner approaches
to caching LINQ data</a> I've seen was on the MSDN Code Gallery web site. Here, the
developer created a sweet extension method that creates the Command object on the
fly, executes the query and caches it all inside a generic method. It bears a little
more review on my part, but its neat enough that I thought I'd share it. Its less
than 50 lines of actual code, but they comment the crap out of it.
</p>
        <p>
The whole idea of having SQL Server notify ASP.Net involves more considerations than
the simplistic approach that served me well for years. For example, I can have SQL
Server watch a specific table, a set of tables, or a specific query (this last options
requires SQL Server 2005 or better). In addition, you'll need to start and stop the
entire process when the application domain comes up and gets recycled respectively.
You probably with a few lines of code in Global.asax. Finally, you're going to need
a few more elements inside your config file that describe a few more details of the
cache behavior. All in all, I like the direction, but I'll be happier when/if the
LINQ story improves.
</p>
        <img width="0" height="0" src="http://www.andrewdothay.net/blog/aggbug.ashx?id=b191edc1-c409-4467-978e-ba58adab6d1d" />
      </body>
      <title>LINQ and the SqlCacheDependency</title>
      <guid isPermaLink="false">http://www.andrewdothay.net/blog/PermaLink,guid,b191edc1-c409-4467-978e-ba58adab6d1d.aspx</guid>
      <link>http://www.andrewdothay.net/blog/2009/01/28/LINQAndTheSqlCacheDependency.aspx</link>
      <pubDate>Wed, 28 Jan 2009 02:57:42 GMT</pubDate>
      <description>&lt;p&gt;
When I've needed to invoke a cache mechanism for data on a web site, I've happily
used the ASP.Net Cache object over the past few years. It's a nice model for storing
a chunk of data under a key until a specific time or for a given duration, providing
the application domain doesn't recycle.
&lt;/p&gt;
&lt;p&gt;
I've even hooked up some systems that resemble a Rube Goldberg apparatus to get the
same features as a job scheduler, but I don't like to talk about them. ASP.Net will
fire an event that you can use when something expires from the cache and therefore
give you the &amp;quot;Cache, Wait, Expire, Do Something, Repeat&amp;quot; model for solving
a job scheduling problem.
&lt;/p&gt;
&lt;p&gt;
.Net 2.0 and up supported the &lt;a href="http://msdn.microsoft.com/en-us/library/system.web.caching.sqlcachedependency.aspx"&gt;SqlCacheDependency&lt;/a&gt; class.
One of its talents is the ability to expire a cached object when the underlying database
changes. Before this feature was available, you might wire up specific cache expiration
logic in relevant insert, update or delete functions of your app. However, that falls
short when the database is updated outside of the trip wires you set in your own code.
Another application might update that database, or someone might edit the database
through Query Analyzer.
&lt;/p&gt;
&lt;p&gt;
Way back in the day, my team set out to bag the big beast by writing a trigger in
SQL Server that would reach out an edit a text file whenever a specific table was
modified. This event would be observed by the cache dependency object that was good
at watching physical files for changes and ska-doosh! We've got our SQL Server cache
dependency working.
&lt;/p&gt;
&lt;p&gt;
Nowadays, those long, verbose methods aren't required. We've got a set of fancy new
tools, namely, the SqlCacheDependency object. Or so I thought.
&lt;/p&gt;
&lt;p&gt;
Its great that support goes all the way back to SQL Server 7, albeit via a costly
polling mechanism. SQL Server 2005 gave us a direct feedback loop that avoided the
polling system. I've know about this feature, as a concept, since it came out but
only in the past few weeks have I really looked at the code to use it and I'm honestly
a little shocked at the site. 
&lt;/p&gt;
&lt;p&gt;
I was really expecting something akin to the familiar practice of checking the cache
for the existence of the object, and if necessary, repopulation of the cache. It turns
out there's a few more steps, and a little craziness if you want to use LINQ to access
your database. 
&lt;/p&gt;
&lt;p&gt;
I'll always leave the door open and hope that some day I'll learn the super easy way
of doing this, but today, so much of this is in the non-trivial bucket that I'm really
tempted to leave it alone and continue my current caching practices.
&lt;/p&gt;
&lt;p&gt;
A year or more ago, I would reach for the data access block inside the &lt;a href="http://www.codeplex.com/entlib"&gt;Enterprise
Library&lt;/a&gt; as a default choice. It's a great data access layer and sure beats writing
all that goo on my own. Today, I'll reach for LINQ as my default choice. As I understand
it, Microsoft is touting the Entity Framework as the future of data access, but today,
I'm still sitting contently in the LINQ boat. Who knows what the future holds for
me.
&lt;/p&gt;
&lt;p&gt;
To be fair, the example code in MSDN that shows how to implement the SqlCacheDependency
actually looks pretty good when you're creating your own Command objects. Not much
to talk about there. But I was disappointed when I looked at the LINQ story. Perhaps
LINQ just got out ahead too far from the pack and better things are coming. 
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://code.msdn.microsoft.com/linqtosqlcache"&gt;One of the cleaner approaches
to caching LINQ data&lt;/a&gt; I've seen was on the MSDN Code Gallery web site. Here, the
developer created a sweet extension method that creates the Command object on the
fly, executes the query and caches it all inside a generic method. It bears a little
more review on my part, but its neat enough that I thought I'd share it. Its less
than 50 lines of actual code, but they comment the crap out of it.
&lt;/p&gt;
&lt;p&gt;
The whole idea of having SQL Server notify ASP.Net involves more considerations than
the simplistic approach that served me well for years. For example, I can have SQL
Server watch a specific table, a set of tables, or a specific query (this last options
requires SQL Server 2005 or better). In addition, you'll need to start and stop the
entire process when the application domain comes up and gets recycled respectively.
You probably with a few lines of code in Global.asax. Finally, you're going to need
a few more elements inside your config file that describe a few more details of the
cache behavior. All in all, I like the direction, but I'll be happier when/if the
LINQ story improves.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.andrewdothay.net/blog/aggbug.ashx?id=b191edc1-c409-4467-978e-ba58adab6d1d" /&gt;</description>
      <comments>http://www.andrewdothay.net/blog/CommentView,guid,b191edc1-c409-4467-978e-ba58adab6d1d.aspx</comments>
      <category>asp.net</category>
      <category>LINQ</category>
    </item>
    <item>
      <trackback:ping>http://www.andrewdothay.net/blog/Trackback.aspx?guid=0da8418b-fa06-4646-95e4-539ca754d570</trackback:ping>
      <pingback:server>http://www.andrewdothay.net/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.andrewdothay.net/blog/PermaLink,guid,0da8418b-fa06-4646-95e4-539ca754d570.aspx</pingback:target>
      <dc:creator>Andrew Hay</dc:creator>
      <wfw:comment>http://www.andrewdothay.net/blog/CommentView,guid,0da8418b-fa06-4646-95e4-539ca754d570.aspx</wfw:comment>
      <wfw:commentRss>http://www.andrewdothay.net/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=0da8418b-fa06-4646-95e4-539ca754d570</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Behind the scenes, I see a lot of companies run on Excel and duct tape. So it's common
for clients to hand me a slab of data organized into neat little rows and columns.
Excel is just a handy way to throw some data over the wall and get things done. This
might be a list of dealers, a collection of user profiles, product information, or
anything that just needs to get somewhere else.
</p>
        <p>
Depending on the scenario, I'll might massage this data and slide it into a SQL Server
database or an XML file. I'm a web developer so I use the ADO.Net stack on a regular
basis. If I were a Windows client developer, I might prefer to solve this problem
with the Excel object model, but that really looks like more code to me, so here's
how I like to roll:
</p>
        <p>
The following code block accepts an Excel file path and returns an ordinary DataTable
object, which can be manipulated easily by the code that calls this method. The first
row of the Excel document becomes the columns in the DataTable object and each row
thereafter are DataRow objects.
</p>
        <p>
          <a href="http://www.andrewdothay.net/blog/content/binary/WindowsLiveWriter/ImportingDataFromExcelwithC_7CBC/ImportDataFromExcel_2.png">
            <img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="148" alt="ImportDataFromExcel" src="http://www.andrewdothay.net/blog/content/binary/WindowsLiveWriter/ImportingDataFromExcelwithC_7CBC/ImportDataFromExcel_thumb.png" width="244" border="0" />
          </a>
          <br />
(Click to enlarge)
</p>
        <p>
If you like, <a href="http://support.microsoft.com/kb/306023">take a look at both
techniques for working with Excel data</a> and see what one speaks to you. With this
block of code, I can happily accept large chunks of data from a client without spending
precious time fiddling with administrivia.
</p>
        <img width="0" height="0" src="http://www.andrewdothay.net/blog/aggbug.ashx?id=0da8418b-fa06-4646-95e4-539ca754d570" />
      </body>
      <title>Importing Data From Excel In C#</title>
      <guid isPermaLink="false">http://www.andrewdothay.net/blog/PermaLink,guid,0da8418b-fa06-4646-95e4-539ca754d570.aspx</guid>
      <link>http://www.andrewdothay.net/blog/2008/07/31/ImportingDataFromExcelInC.aspx</link>
      <pubDate>Thu, 31 Jul 2008 16:00:16 GMT</pubDate>
      <description>&lt;p&gt;
Behind the scenes, I see a lot of companies run on Excel and duct tape. So it's common
for clients to hand me a slab of data organized into neat little rows and columns.
Excel is just a handy way to throw some data over the wall and get things done. This
might be a list of dealers, a collection of user profiles, product information, or
anything that just needs to get somewhere else.
&lt;/p&gt;
&lt;p&gt;
Depending on the scenario, I'll might massage this data and slide it into a SQL Server
database or an XML file. I'm a web developer so I use the ADO.Net stack on a regular
basis. If I were a Windows client developer, I might prefer to solve this problem
with the Excel object model, but that really looks like more code to me, so here's
how I like to roll:
&lt;/p&gt;
&lt;p&gt;
The following code block accepts an Excel file path and returns an ordinary DataTable
object, which can be manipulated easily by the code that calls this method. The first
row of the Excel document becomes the columns in the DataTable object and each row
thereafter are DataRow objects.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.andrewdothay.net/blog/content/binary/WindowsLiveWriter/ImportingDataFromExcelwithC_7CBC/ImportDataFromExcel_2.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="148" alt="ImportDataFromExcel" src="http://www.andrewdothay.net/blog/content/binary/WindowsLiveWriter/ImportingDataFromExcelwithC_7CBC/ImportDataFromExcel_thumb.png" width="244" border="0" /&gt;&lt;/a&gt; 
&lt;br /&gt;
(Click to enlarge)
&lt;/p&gt;
&lt;p&gt;
If you like, &lt;a href="http://support.microsoft.com/kb/306023"&gt;take a look at both
techniques for working with Excel data&lt;/a&gt; and see what one speaks to you. With this
block of code, I can happily accept large chunks of data from a client without spending
precious time fiddling with administrivia.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.andrewdothay.net/blog/aggbug.ashx?id=0da8418b-fa06-4646-95e4-539ca754d570" /&gt;</description>
      <comments>http://www.andrewdothay.net/blog/CommentView,guid,0da8418b-fa06-4646-95e4-539ca754d570.aspx</comments>
      <category>asp.net</category>
      <category>software</category>
      <category>SQL Server</category>
      <category>Visual Studio</category>
    </item>
    <item>
      <trackback:ping>http://www.andrewdothay.net/blog/Trackback.aspx?guid=a05314be-a70f-42e1-aa5c-b2dcd98bb5d9</trackback:ping>
      <pingback:server>http://www.andrewdothay.net/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.andrewdothay.net/blog/PermaLink,guid,a05314be-a70f-42e1-aa5c-b2dcd98bb5d9.aspx</pingback:target>
      <dc:creator>Andrew Hay</dc:creator>
      <wfw:comment>http://www.andrewdothay.net/blog/CommentView,guid,a05314be-a70f-42e1-aa5c-b2dcd98bb5d9.aspx</wfw:comment>
      <wfw:commentRss>http://www.andrewdothay.net/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=a05314be-a70f-42e1-aa5c-b2dcd98bb5d9</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Joel Spolsky (of <a href="http://www.joelonsoftware.com/)">http://www.joelonsoftware.com/)</a> and
Jeff Atwood (of <a href="http://www.codinghorror.com/blog/)">http://www.codinghorror.com/blog/)</a> selected
my audio question on their new podcast, episode #6. 
</p>
        <p>
Stackoverflow is a new property created by a joint venture between these two blogging
juggernauts. 
</p>
        <p>
          <a href="http://blog.stackoverflow.com/">http://blog.stackoverflow.com/</a>
        </p>
        <p>
So far, their podcast is interesting like Paris Hilton. She’s famous for just
being herself. Nevertheless, I am now famous.
</p>
        <p>
I really do look forward to each new episode. Its a nice change of pace from the others
that decorate my new iPhone. It's a little like a Seinfeld episode too, its a show
about nothing, but in that span of 30 minutes, something interesting always happens.
I love the history that Joel sprinkles in and the minutia that intrigues Jeff so much.
</p>
        <p>
My question picked a little bit on Jeff, but hopefully the core of it came through.
It was essentially a version of the eternal buy vs. build issue, or in this case "use
what's in the box" vs. "build your own" scenario. Jeff had a respectable
answer that centered on what he felt was important and what he was happy to inherit
from the .Net Framework. 
</p>
        <p>
These are the types of debates I have every day building software. Its fun to ping
someone outside your normal group every now and again and see what they have to say
about it.
</p>
        <img width="0" height="0" src="http://www.andrewdothay.net/blog/aggbug.ashx?id=a05314be-a70f-42e1-aa5c-b2dcd98bb5d9" />
      </body>
      <title>Joel Spolsky Agrees With Me</title>
      <guid isPermaLink="false">http://www.andrewdothay.net/blog/PermaLink,guid,a05314be-a70f-42e1-aa5c-b2dcd98bb5d9.aspx</guid>
      <link>http://www.andrewdothay.net/blog/2008/05/22/JoelSpolskyAgreesWithMe.aspx</link>
      <pubDate>Thu, 22 May 2008 18:35:52 GMT</pubDate>
      <description>&lt;p&gt;
Joel Spolsky (of &lt;a href="http://www.joelonsoftware.com/)"&gt;http://www.joelonsoftware.com/)&lt;/a&gt; and
Jeff Atwood (of &lt;a href="http://www.codinghorror.com/blog/)"&gt;http://www.codinghorror.com/blog/)&lt;/a&gt; selected
my audio question on their new podcast, episode #6. 
&lt;/p&gt;
&lt;p&gt;
Stackoverflow is a new property created by a joint venture between these two blogging
juggernauts. 
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blog.stackoverflow.com/"&gt;http://blog.stackoverflow.com/&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
So far, their podcast is interesting like Paris Hilton. She&amp;#8217;s famous for just
being herself. Nevertheless, I am now famous.
&lt;/p&gt;
&lt;p&gt;
I really do look forward to each new episode. Its a nice change of pace from the others
that decorate my new iPhone. It's a little like a Seinfeld episode too, its a show
about nothing, but in that span of 30 minutes, something interesting always happens.
I love the history that Joel sprinkles in and the minutia that intrigues Jeff so much.
&lt;/p&gt;
&lt;p&gt;
My question picked a little bit on Jeff, but hopefully the core of it came through.
It was essentially a version of the eternal buy vs. build issue, or in this case &amp;quot;use
what's in the box&amp;quot; vs. &amp;quot;build your own&amp;quot; scenario. Jeff had a respectable
answer that centered on what he felt was important and what he was happy to inherit
from the .Net Framework. 
&lt;/p&gt;
&lt;p&gt;
These are the types of debates I have every day building software. Its fun to ping
someone outside your normal group every now and again and see what they have to say
about it.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.andrewdothay.net/blog/aggbug.ashx?id=a05314be-a70f-42e1-aa5c-b2dcd98bb5d9" /&gt;</description>
      <comments>http://www.andrewdothay.net/blog/CommentView,guid,a05314be-a70f-42e1-aa5c-b2dcd98bb5d9.aspx</comments>
      <category>asp.net</category>
      <category>blogging</category>
    </item>
    <item>
      <trackback:ping>http://www.andrewdothay.net/blog/Trackback.aspx?guid=6fa66dea-4cad-4891-9edf-0ddd02bdc551</trackback:ping>
      <pingback:server>http://www.andrewdothay.net/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.andrewdothay.net/blog/PermaLink,guid,6fa66dea-4cad-4891-9edf-0ddd02bdc551.aspx</pingback:target>
      <dc:creator>Andrew Hay</dc:creator>
      <wfw:comment>http://www.andrewdothay.net/blog/CommentView,guid,6fa66dea-4cad-4891-9edf-0ddd02bdc551.aspx</wfw:comment>
      <wfw:commentRss>http://www.andrewdothay.net/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=6fa66dea-4cad-4891-9edf-0ddd02bdc551</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I spent a little too long on this rainy Sunday afternoon tripping over myself. I'm
using the SqlDataSource and the FormView controls in a quick prototype. I clicked
the "Use optimistic concurrency" field in the SqlDataSource configuration page so
it would compare the original values before updating the database. 
</p>
        <p>
I was going along fine when I realized the updates didn't work, but the insert was
OK. After several repeated attempts with zero rows updates, I fired up the SQL Profiler
and saw my update query right there, plain as day. Why wasn't the update working?
</p>
        <p>
          <img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="383" alt="sql-profiler" src="http://www.andrewdothay.net/blog/content/binary/WindowsLiveWriter/MillisecondUpdateProblemwithSqlDataSourc_10455/sql-profiler_3.png" width="590" border="0" />
        </p>
        <p>
I even grabbed the SQL out of SQL Profiler and ran it through Query Analyzer - and
then bam! I could see it on my screen. The milliseconds for the date time fields were
all set to zero, and the actual values in the database were non-zero values. Who was
loosing the milliseconds?
</p>
        <p>
Finally, it hit me. I was losing the data.
</p>
        <p>
I was trying to be real smart about setting the hidden "Created" and "Modified" DateTime
fields during the updating event of the SqlDataSource control. I would do a similar
assignment during the update event for just the "Modified" DateTime field.
</p>
        <pre class="brush: js">
protected void SqlDataSource1_Inserting(object sender, SqlDataSourceCommandEventArgs e)
{
   DateTime now = DateTime.Now;

   e.Command.Parameters["@Created"].Value = now;
   e.Command.Parameters["@Modified"].Value = now;
}
</pre>
        <p>
As I was peering at this method, it struck me that I was inadvertently setting the
fields to a value that was too granular for my SqlDataSource object. It wasn't passing
back the millisecond value, so I compensated by making sure the value is always zero
milliseconds, like so:
</p>
        <pre style="border-right: #999999 1px dashed; padding-right: 5px; border-top: #999999 1px dashed; padding-left: 5px; font-size: 12px; padding-bottom: 5px; border-left: #999999 1px dashed; width: 100%; color: #000000; line-height: 14px; padding-top: 5px; border-bottom: #999999 1px dashed; font-family: andale mono, lucida console, monaco, fixed, monospace; background-color: #eee">
          <code>protected
void SqlDataSource1_Inserting(object sender, SqlDataSourceCommandEventArgs e) { DateTime
now = DateTime.Now; now = now.AddMilliseconds(1000 - now.Millisecond); e.Command.Parameters["@Created"].Value
= now; e.Command.Parameters["@Modified"].Value = now; } </code>
        </pre>
        <p>
With this adjustment, my inserts and updates are playing nicely. Yay! 
</p>
        <p>
So, now that i works, I'm still not real happy with it. I'd much rather have the code
check a single timestamp column named "Version" than see all that bloat in there.
</p>
        <img width="0" height="0" src="http://www.andrewdothay.net/blog/aggbug.ashx?id=6fa66dea-4cad-4891-9edf-0ddd02bdc551" />
      </body>
      <title>Millisecond Update Problem with SqlDataSource</title>
      <guid isPermaLink="false">http://www.andrewdothay.net/blog/PermaLink,guid,6fa66dea-4cad-4891-9edf-0ddd02bdc551.aspx</guid>
      <link>http://www.andrewdothay.net/blog/2008/03/24/MillisecondUpdateProblemWithSqlDataSource.aspx</link>
      <pubDate>Mon, 24 Mar 2008 01:30:47 GMT</pubDate>
      <description>&lt;p&gt;
I spent a little too long on this rainy Sunday afternoon tripping over myself. I'm
using the SqlDataSource and the FormView controls in a quick prototype. I clicked
the "Use optimistic concurrency" field in the SqlDataSource configuration page so
it would compare the original values before updating the database. 
&lt;/p&gt;
&lt;p&gt;
I was going along fine when I realized the updates didn't work, but the insert was
OK. After several repeated attempts with zero rows updates, I fired up the SQL Profiler
and saw my update query right there, plain as day. Why wasn't the update working?
&lt;/p&gt;
&lt;p&gt;
&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="383" alt="sql-profiler" src="http://www.andrewdothay.net/blog/content/binary/WindowsLiveWriter/MillisecondUpdateProblemwithSqlDataSourc_10455/sql-profiler_3.png" width="590" border="0" /&gt;
&lt;/p&gt;
&lt;p&gt;
I even grabbed the SQL out of SQL Profiler and ran it through Query Analyzer - and
then bam! I could see it on my screen. The milliseconds for the date time fields were
all set to zero, and the actual values in the database were non-zero values. Who was
loosing the milliseconds?
&lt;/p&gt;
&lt;p&gt;
Finally, it hit me. I was losing the data.
&lt;/p&gt;
&lt;p&gt;
I was trying to be real smart about setting the hidden "Created" and "Modified" DateTime
fields during the updating event of the SqlDataSource control. I would do a similar
assignment during the update event for just the "Modified" DateTime field.
&lt;/p&gt;
&lt;pre class="brush: js"&gt;
protected void SqlDataSource1_Inserting(object sender, SqlDataSourceCommandEventArgs e)
{
   DateTime now = DateTime.Now;

   e.Command.Parameters["@Created"].Value = now;
   e.Command.Parameters["@Modified"].Value = now;
}
&lt;/pre&gt;
&lt;p&gt;
As I was peering at this method, it struck me that I was inadvertently setting the
fields to a value that was too granular for my SqlDataSource object. It wasn't passing
back the millisecond value, so I compensated by making sure the value is always zero
milliseconds, like so:
&lt;/p&gt;
&lt;pre style="border-right: #999999 1px dashed; padding-right: 5px; border-top: #999999 1px dashed; padding-left: 5px; font-size: 12px; padding-bottom: 5px; border-left: #999999 1px dashed; width: 100%; color: #000000; line-height: 14px; padding-top: 5px; border-bottom: #999999 1px dashed; font-family: andale mono, lucida console, monaco, fixed, monospace; background-color: #eee"&gt;&lt;code&gt;protected
void SqlDataSource1_Inserting(object sender, SqlDataSourceCommandEventArgs e) { DateTime
now = DateTime.Now; now = now.AddMilliseconds(1000 - now.Millisecond); e.Command.Parameters["@Created"].Value
= now; e.Command.Parameters["@Modified"].Value = now; } &lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
With this adjustment, my inserts and updates are playing nicely. Yay! 
&lt;/p&gt;
&lt;p&gt;
So, now that i works, I'm still not real happy with it. I'd much rather have the code
check a single timestamp column named "Version" than see all that bloat in there.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.andrewdothay.net/blog/aggbug.ashx?id=6fa66dea-4cad-4891-9edf-0ddd02bdc551" /&gt;</description>
      <comments>http://www.andrewdothay.net/blog/CommentView,guid,6fa66dea-4cad-4891-9edf-0ddd02bdc551.aspx</comments>
      <category>asp.net</category>
      <category>SQL Server</category>
    </item>
    <item>
      <trackback:ping>http://www.andrewdothay.net/blog/Trackback.aspx?guid=41cfded7-f3e7-4733-97b2-bd9ddefe8228</trackback:ping>
      <pingback:server>http://www.andrewdothay.net/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.andrewdothay.net/blog/PermaLink,guid,41cfded7-f3e7-4733-97b2-bd9ddefe8228.aspx</pingback:target>
      <dc:creator>Andrew Hay</dc:creator>
      <wfw:comment>http://www.andrewdothay.net/blog/CommentView,guid,41cfded7-f3e7-4733-97b2-bd9ddefe8228.aspx</wfw:comment>
      <wfw:commentRss>http://www.andrewdothay.net/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=41cfded7-f3e7-4733-97b2-bd9ddefe8228</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
One of my teammates recently had a problem with some Flash injection code. She was
setting some properties and then calling a function on a JavaScript object that threw
an error. We got a message that said "Object doesn't support this property or
method".
</p>
        <p>
 <img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="294" alt="Object doesn't support this property or method" src="http://www.andrewdothay.net/blog/content/binary/WindowsLiveWriter/TestforExistenceofaJavaScriptMethod_14218/image_6.png" width="447" border="0" /></p>
        <p>
We isolated it down to a timing issue by dropping an alert() into the code just before
we called the method. With the alert() pausing execution for a few seconds, the browser
had enough time to fully instantiate our object. Without the alert(), the method was
called before it was built. Its a problem that can make your brain hurt.
</p>
        <p>
Here's how you can test for the existence of a JavaScript method before you call it.
You might need to do this if you're working with asynchronous calls or dynamic objects
that take a while to build.
</p>
        <p>
I created a sample page to demonstrate the issue and how to deal with it. I put three
hyperlinks on the page that each call a JavaScript method. Here's the JavaScript code.
</p>
        <p>
          <a href="http://www.andrewdothay.net/blog/content/binary/WindowsLiveWriter/TestforExistenceofaJavaScriptMethod_14218/image_10.png">
            <img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="850" alt="Testing for a JavaScript method" src="http://www.andrewdothay.net/blog/content/binary/WindowsLiveWriter/TestforExistenceofaJavaScriptMethod_14218/image_thumb_3.png" width="579" border="0" />
          </a>
        </p>
        <p>
At the bottom of the previous code block, you'll see some JavaScript in the mainline
section. This code gets executed as soon as the browser sees it. JavaScript is an
interpreted language and the browser processes it in a top-down fashion. So, by definition,
the browser already knows about my three methods before it runs my code in the mainline. 
This is where I define an empty object to test and then create an instance of that
object. Just two lines, not much so far.
</p>
        <p>
When I click the link that runs the function named TestForFunction(), I perform some
due diligence tests by checking for an undefined object as well as a null object.
The last test with the arrow pointing to it is the key part. This will tell me if
the method exists without actually running the method. I show one of two messages
based on the existence of the method.
</p>
        <p>
The top function named CreateFunction() just spot welds a method onto my object. Even
though I've already created an instance of my object, I can still see this method
in my instance because I've added the method to the prototype. When this function
returns, I've got my new method. When I run TestForFUnction() again, it will see the
method.
</p>
        <p>
The bottom method just executes the function I added on the fly. When my DoWork()
method fires, it shows a message in the alert() pop-up. 
</p>
        <p>
If you find that you need to deal with this type of problem in your code, inspect
the object for the method before you call it. If the method doesn't exist, refactor
your code to call the window.setTimeout() function for a few milliseconds and check
again. Once it exists, your code can continue executing.
</p>
        <img width="0" height="0" src="http://www.andrewdothay.net/blog/aggbug.ashx?id=41cfded7-f3e7-4733-97b2-bd9ddefe8228" />
      </body>
      <title>Test for Existence of a JavaScript Method</title>
      <guid isPermaLink="false">http://www.andrewdothay.net/blog/PermaLink,guid,41cfded7-f3e7-4733-97b2-bd9ddefe8228.aspx</guid>
      <link>http://www.andrewdothay.net/blog/2008/02/16/TestForExistenceOfAJavaScriptMethod.aspx</link>
      <pubDate>Sat, 16 Feb 2008 06:54:22 GMT</pubDate>
      <description>&lt;p&gt;
One of my teammates recently had a problem with some Flash injection code. She was
setting some properties and then calling a function on a JavaScript object that threw
an error. We got a message that said &amp;quot;Object doesn't support this property or
method&amp;quot;.
&lt;/p&gt;
&lt;p&gt;
&amp;#160;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="294" alt="Object doesn&amp;#39;t support this property or method" src="http://www.andrewdothay.net/blog/content/binary/WindowsLiveWriter/TestforExistenceofaJavaScriptMethod_14218/image_6.png" width="447" border="0" /&gt; 
&lt;/p&gt;
&lt;p&gt;
We isolated it down to a timing issue by dropping an alert() into the code just before
we called the method. With the alert() pausing execution for a few seconds, the browser
had enough time to fully instantiate our object. Without the alert(), the method was
called before it was built. Its a problem that can make your brain hurt.
&lt;/p&gt;
&lt;p&gt;
Here's how you can test for the existence of a JavaScript method before you call it.
You might need to do this if you're working with asynchronous calls or dynamic objects
that take a while to build.
&lt;/p&gt;
&lt;p&gt;
I created a sample page to demonstrate the issue and how to deal with it. I put three
hyperlinks on the page that each call a JavaScript method. Here's the JavaScript code.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.andrewdothay.net/blog/content/binary/WindowsLiveWriter/TestforExistenceofaJavaScriptMethod_14218/image_10.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="850" alt="Testing for a JavaScript method" src="http://www.andrewdothay.net/blog/content/binary/WindowsLiveWriter/TestforExistenceofaJavaScriptMethod_14218/image_thumb_3.png" width="579" border="0" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
At the bottom of the previous code block, you'll see some JavaScript in the mainline
section. This code gets executed as soon as the browser sees it. JavaScript is an
interpreted language and the browser processes it in a top-down fashion. So, by definition,
the browser already knows about my three methods before it runs my code in the mainline.&amp;#160;
This is where I define an empty object to test and then create an instance of that
object. Just two lines, not much so far.
&lt;/p&gt;
&lt;p&gt;
When I click the link that runs the function named TestForFunction(), I perform some
due diligence tests by checking for an undefined object as well as a null object.
The last test with the arrow pointing to it is the key part. This will tell me if
the method exists without actually running the method. I show one of two messages
based on the existence of the method.
&lt;/p&gt;
&lt;p&gt;
The top function named CreateFunction() just spot welds a method onto my object. Even
though I've already created an instance of my object, I can still see this method
in my instance because I've added the method to the prototype. When this function
returns, I've got my new method. When I run TestForFUnction() again, it will see the
method.
&lt;/p&gt;
&lt;p&gt;
The bottom method just executes the function I added on the fly. When my DoWork()
method fires, it shows a message in the alert() pop-up. 
&lt;/p&gt;
&lt;p&gt;
If you find that you need to deal with this type of problem in your code, inspect
the object for the method before you call it. If the method doesn't exist, refactor
your code to call the window.setTimeout() function for a few milliseconds and check
again. Once it exists, your code can continue executing.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.andrewdothay.net/blog/aggbug.ashx?id=41cfded7-f3e7-4733-97b2-bd9ddefe8228" /&gt;</description>
      <comments>http://www.andrewdothay.net/blog/CommentView,guid,41cfded7-f3e7-4733-97b2-bd9ddefe8228.aspx</comments>
      <category>asp.net</category>
      <category>ie7</category>
    </item>
    <item>
      <trackback:ping>http://www.andrewdothay.net/blog/Trackback.aspx?guid=7ce4adfc-8bc1-46ed-9d0e-9146550295b1</trackback:ping>
      <pingback:server>http://www.andrewdothay.net/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.andrewdothay.net/blog/PermaLink,guid,7ce4adfc-8bc1-46ed-9d0e-9146550295b1.aspx</pingback:target>
      <dc:creator>Andrew Hay</dc:creator>
      <wfw:comment>http://www.andrewdothay.net/blog/CommentView,guid,7ce4adfc-8bc1-46ed-9d0e-9146550295b1.aspx</wfw:comment>
      <wfw:commentRss>http://www.andrewdothay.net/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=7ce4adfc-8bc1-46ed-9d0e-9146550295b1</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I got a favorable message, so I reckon its not all that bad.
</p>
        <p>
          <a title="http://www.lhotka.net/weblog/MagenicWantsYouThisTimeWithAQuiz.aspx" href="http://www.lhotka.net/weblog/MagenicWantsYouThisTimeWithAQuiz.aspx">http://www.lhotka.net/weblog/MagenicWantsYouThisTimeWithAQuiz.aspx</a>
        </p>
        <p>
After all, Rocky got an 84. I think I rocked most of the ASP.Net questions, but the
smart client stuff and multi-threading is a little foreign to me.
</p>
        <p>
What did you get?
</p>
        <img width="0" height="0" src="http://www.andrewdothay.net/blog/aggbug.ashx?id=7ce4adfc-8bc1-46ed-9d0e-9146550295b1" />
      </body>
      <title>Hey, I got 59 out of 100!</title>
      <guid isPermaLink="false">http://www.andrewdothay.net/blog/PermaLink,guid,7ce4adfc-8bc1-46ed-9d0e-9146550295b1.aspx</guid>
      <link>http://www.andrewdothay.net/blog/2007/11/28/HeyIGot59OutOf100.aspx</link>
      <pubDate>Wed, 28 Nov 2007 08:07:19 GMT</pubDate>
      <description>&lt;p&gt;
I got a favorable message, so I reckon its not all that bad.
&lt;/p&gt;
&lt;p&gt;
&lt;a title="http://www.lhotka.net/weblog/MagenicWantsYouThisTimeWithAQuiz.aspx" href="http://www.lhotka.net/weblog/MagenicWantsYouThisTimeWithAQuiz.aspx"&gt;http://www.lhotka.net/weblog/MagenicWantsYouThisTimeWithAQuiz.aspx&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
After all, Rocky got an 84. I think I rocked most of the ASP.Net questions, but the
smart client stuff and multi-threading is a little foreign to me.
&lt;/p&gt;
&lt;p&gt;
What did you get?
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.andrewdothay.net/blog/aggbug.ashx?id=7ce4adfc-8bc1-46ed-9d0e-9146550295b1" /&gt;</description>
      <comments>http://www.andrewdothay.net/blog/CommentView,guid,7ce4adfc-8bc1-46ed-9d0e-9146550295b1.aspx</comments>
      <category>asp.net</category>
      <category>blogging</category>
    </item>
    <item>
      <trackback:ping>http://www.andrewdothay.net/blog/Trackback.aspx?guid=e723c2e5-fc82-48cf-b437-b9f34781df0e</trackback:ping>
      <pingback:server>http://www.andrewdothay.net/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.andrewdothay.net/blog/PermaLink,guid,e723c2e5-fc82-48cf-b437-b9f34781df0e.aspx</pingback:target>
      <dc:creator>Andrew Hay</dc:creator>
      <wfw:comment>http://www.andrewdothay.net/blog/CommentView,guid,e723c2e5-fc82-48cf-b437-b9f34781df0e.aspx</wfw:comment>
      <wfw:commentRss>http://www.andrewdothay.net/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=e723c2e5-fc82-48cf-b437-b9f34781df0e</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I was working with a web service client that talked to SharePoint this week. I wrote
a quick Silverlight app that extracted a list of tasks out of a SharePoint list. I
love how simple this is to tap into:
</p>
        <p>
          <code>
            <a href="http://sharepoint.yourcompany.com/_vti_bin/lists.asmx">http://sharepoint.yourcompany.com/_vti_bin/lists.asmx</a>
          </code>
        </p>
        <p>
The previous URL will show the path to one of the web services provided out-of-the-box
by SharePoint. This particular web service provides several methods for dealing with
SharePoint lists. I just needed to call the GetListItems() method and pass in the
list name and view name as parameters in order to get my data.
</p>
        <p>
This worked fine on my local machine, but when I migrated the solution to a staging
server, the SharePoint web service refused to send me the data. After a bit of finagling,
I realized the web service was happy to talk to my laptop, but it politely declined
the remote web server's request as I lacked the proper credentials. I even was running
the web solution with impersonation enabled because I wanted to pass along my Windows
credentials during the call from the web server to the remote SharePoint server. I
forgot that this is just simply not possible. 
</p>
        <p>
For security reasons, the web server does not hold on to my credentials "just
in case" I might want to use them later. In this scenario, I do need them - but
no dice. This particular list in SharePoint is locked down tight.
</p>
        <p>
I didn't have the proper credentials when my web service client fired off a request
to SharePoint. When I was running on my local machine, using Casinni, my credentials
were readily available. On a remote web server, the credentials vanish. This is called
a "Double Hop" problem - the hops are from the browser, to the web server,
to another remote web server. The second hop tanked. It was a silly mistake on my
part, but hopefully by writing this down now will help me remember sooner next time.
</p>
        <p>
The code below shows how I solve this problem by manufacturing a credential on-the-fly
and then fire off a request to SharePoint. There are multiple ways of solving this
problem; I just happened to chose this one.
</p>
        <div style="padding-right: 0px; padding-left: 0px; background: #eee; padding-bottom: 20px; padding-top: 20px">
          <pre>         MySharePoint.Lists list = new ProjectBoard.MySharePoint.Lists();</pre>
          <pre> </pre>
          <pre>         list.Credentials = new System.Net.NetworkCredential(</pre>
          <pre>            ConfigurationManager.AppSettings["Credential.Username"],</pre>
          <pre>            ConfigurationManager.AppSettings["Credential.Password"],</pre>
          <pre>            ConfigurationManager.AppSettings["Credential.Domain"]);</pre>
          <pre> </pre>
          <pre>         XmlNode listItemsNode = list.GetListItems(</pre>
          <pre>            ConfigurationManager.AppSettings["LoremIpsum.Guid"], </pre>
          <pre>            ConfigurationManager.AppSettings["LoremIpsum.View.Guid"], </pre>
          <pre>            null, null, "100", null, null);</pre>
          <pre> </pre>
          <pre>         XmlNode dataNode = listItemsNode.ChildNodes[1];</pre>
          <pre> </pre>
          <pre>         foreach (XmlNode rowNode in dataNode.ChildNodes)</pre>
          <pre>         {</pre>
          <pre>           // extract values here</pre>
          <pre>         }</pre>
        </div>
        <p>
Now that I've got this little prototype functional, I can encrypt the credentials
in the web.config file by using <a href="http://msdn2.microsoft.com/en-us/library/ms998280.aspx" target="_blank">DPAPI</a>,
an encryption tool that makes it easy to protect sensitive information. Since I'm
creating new credentials here, I can avoid the Double Hop problem and get on with
my prototype.
</p>
        <img width="0" height="0" src="http://www.andrewdothay.net/blog/aggbug.ashx?id=e723c2e5-fc82-48cf-b437-b9f34781df0e" />
      </body>
      <title>Double Hop Disaster</title>
      <guid isPermaLink="false">http://www.andrewdothay.net/blog/PermaLink,guid,e723c2e5-fc82-48cf-b437-b9f34781df0e.aspx</guid>
      <link>http://www.andrewdothay.net/blog/2007/11/10/DoubleHopDisaster.aspx</link>
      <pubDate>Sat, 10 Nov 2007 06:03:14 GMT</pubDate>
      <description>&lt;p&gt;
I was working with a web service client that talked to SharePoint this week. I wrote
a quick Silverlight app that extracted a list of tasks out of a SharePoint list. I
love how simple this is to tap into:
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;&lt;a href="http://sharepoint.yourcompany.com/_vti_bin/lists.asmx"&gt;http://sharepoint.yourcompany.com/_vti_bin/lists.asmx&lt;/a&gt;&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
The previous URL will show the path to one of the web services provided out-of-the-box
by SharePoint. This particular web service provides several methods for dealing with
SharePoint lists. I just needed to call the GetListItems() method and pass in the
list name and view name as parameters in order to get my data.
&lt;/p&gt;
&lt;p&gt;
This worked fine on my local machine, but when I migrated the solution to a staging
server, the SharePoint web service refused to send me the data. After a bit of finagling,
I realized the web service was happy to talk to my laptop, but it politely declined
the remote web server's request as I lacked the proper credentials. I even was running
the web solution with impersonation enabled because I wanted to pass along my Windows
credentials during the call from the web server to the remote SharePoint server. I
forgot that this is just simply not possible. 
&lt;/p&gt;
&lt;p&gt;
For security reasons, the web server does not hold on to my credentials &amp;quot;just
in case&amp;quot; I might want to use them later. In this scenario, I do need them - but
no dice. This particular list in SharePoint is locked down tight.
&lt;/p&gt;
&lt;p&gt;
I didn't have the proper credentials when my web service client fired off a request
to SharePoint. When I was running on my local machine, using Casinni, my credentials
were readily available. On a remote web server, the credentials vanish. This is called
a &amp;quot;Double Hop&amp;quot; problem - the hops are from the browser, to the web server,
to another remote web server. The second hop tanked. It was a silly mistake on my
part, but hopefully by writing this down now will help me remember sooner next time.
&lt;/p&gt;
&lt;p&gt;
The code below shows how I solve this problem by manufacturing a credential on-the-fly
and then fire off a request to SharePoint. There are multiple ways of solving this
problem; I just happened to chose this one.
&lt;/p&gt;
&lt;div style="padding-right: 0px; padding-left: 0px; background: #eee; padding-bottom: 20px; padding-top: 20px"&gt;
&lt;pre&gt;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0; MySharePoint.Lists list = new ProjectBoard.MySharePoint.Lists();&lt;/pre&gt;
&lt;pre&gt;&amp;#xA0;&lt;/pre&gt;
&lt;pre&gt;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0; list.Credentials = new System.Net.NetworkCredential(&lt;/pre&gt;
&lt;pre&gt;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0; ConfigurationManager.AppSettings[&amp;quot;Credential.Username&amp;quot;],&lt;/pre&gt;
&lt;pre&gt;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0; ConfigurationManager.AppSettings[&amp;quot;Credential.Password&amp;quot;],&lt;/pre&gt;
&lt;pre&gt;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0; ConfigurationManager.AppSettings[&amp;quot;Credential.Domain&amp;quot;]);&lt;/pre&gt;
&lt;pre&gt;&amp;#xA0;&lt;/pre&gt;
&lt;pre&gt;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0; XmlNode listItemsNode = list.GetListItems(&lt;/pre&gt;
&lt;pre&gt;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0; ConfigurationManager.AppSettings[&amp;quot;LoremIpsum.Guid&amp;quot;], &lt;/pre&gt;
&lt;pre&gt;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0; ConfigurationManager.AppSettings[&amp;quot;LoremIpsum.View.Guid&amp;quot;], &lt;/pre&gt;
&lt;pre&gt;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0; null, null, &amp;quot;100&amp;quot;, null, null);&lt;/pre&gt;
&lt;pre&gt;&amp;#xA0;&lt;/pre&gt;
&lt;pre&gt;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0; XmlNode dataNode = listItemsNode.ChildNodes[1];&lt;/pre&gt;
&lt;pre&gt;&amp;#xA0;&lt;/pre&gt;
&lt;pre&gt;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0; foreach (XmlNode rowNode in dataNode.ChildNodes)&lt;/pre&gt;
&lt;pre&gt;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0; {&lt;/pre&gt;
&lt;pre&gt;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0; // extract values here&lt;/pre&gt;
&lt;pre&gt;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0;&amp;#xA0; }&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;
Now that I've got this little prototype functional, I can encrypt the credentials
in the web.config file by using &lt;a href="http://msdn2.microsoft.com/en-us/library/ms998280.aspx" target="_blank"&gt;DPAPI&lt;/a&gt;,
an encryption tool that makes it easy to protect sensitive information. Since I'm
creating new credentials here, I can avoid the Double Hop problem and get on with
my prototype.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.andrewdothay.net/blog/aggbug.ashx?id=e723c2e5-fc82-48cf-b437-b9f34781df0e" /&gt;</description>
      <comments>http://www.andrewdothay.net/blog/CommentView,guid,e723c2e5-fc82-48cf-b437-b9f34781df0e.aspx</comments>
      <category>asp.net</category>
      <category>SharePoint</category>
      <category>Silverlight</category>
    </item>
    <item>
      <trackback:ping>http://www.andrewdothay.net/blog/Trackback.aspx?guid=381983fa-7cf2-4a89-9fa4-d669c33ba0f2</trackback:ping>
      <pingback:server>http://www.andrewdothay.net/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.andrewdothay.net/blog/PermaLink,guid,381983fa-7cf2-4a89-9fa4-d669c33ba0f2.aspx</pingback:target>
      <dc:creator>Andrew Hay</dc:creator>
      <wfw:comment>http://www.andrewdothay.net/blog/CommentView,guid,381983fa-7cf2-4a89-9fa4-d669c33ba0f2.aspx</wfw:comment>
      <wfw:commentRss>http://www.andrewdothay.net/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=381983fa-7cf2-4a89-9fa4-d669c33ba0f2</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
About a year ago, I attended an MSDN event in my area and won the boobie prize: 12
months of free hosting from an vendor at the event. I had been hosting my site
on my company's web servers, so that seemed like a good opportunity to leave the nest
and test my skills in the wild. Plus, the price was right.
</p>
        <p>
Man, did that suck.
</p>
        <p>
On Wednesday, I signed up for 12 months of hosting with <a href="http://www.discountasp.net/index.aspx">DiscountASP.Net</a>.
They advertised on <a href="http://www.asp.net">www.asp.net</a>, and had a lot of
good word-of-mouth referrals that eached my ears.
</p>
        <p>
In the matter of about an hour, I did the following:
</p>
        <ul>
          <li>
Completed an online transaction with DiscountASP.net 
</li>
          <li>
Accessed my new site through the Control Panel provided by DiscountASP.Net 
</li>
          <li>
Downloaded the latest <a href="http://dasblog.info/">dasBlog</a> bits for ASP.Net
2.0, medium trust 
</li>
          <li>
Uploaded the dasBlog bits to my new site 
</li>
          <li>
Switched the DNS servers to my new ISP 
</li>
          <li>
Moved the content folder from my old host to DiscountASP.Net 
</li>
          <li>
Minor configuration to secure and customize my blog</li>
        </ul>
        <p>
I'll have you know that I have not yet contacted DiscountASP.Net by phone or e-mail,
nor have I had to read their online help documents. The entire process was smooth
as silk. I was shocked. My previous personal and professional experiences have always
left me in need of some type of resolution.
</p>
        <p>
This is how it should be — DiscountASP.Net has done a great job and I'm grateful.
</p>
        <p>
I was also relieved by the ease of my dasBlog upgrade. I was about a year off the
head in their source code repository. The new version has several sweet skins
out-of-the-box and they're easy to customize. 
</p>
        <p>
I highly recommend dasBlog for any type of blogging solution — it's a rock solid open
source system under active development. Now that I'm 99% out-from-under of my enormous
eight month project, I'd love to saunter over to that open source project and try
my hand at helping the dasBlog dev team. The weekend is just starting, Le
Wife is out of town, and I'm dinking around on a new laptop with Vista. Can't ask
for a better set up than that!
</p>
        <img width="0" height="0" src="http://www.andrewdothay.net/blog/aggbug.ashx?id=381983fa-7cf2-4a89-9fa4-d669c33ba0f2" />
      </body>
      <title>dasBlog v2.0 and discountASP.Net</title>
      <guid isPermaLink="false">http://www.andrewdothay.net/blog/PermaLink,guid,381983fa-7cf2-4a89-9fa4-d669c33ba0f2.aspx</guid>
      <link>http://www.andrewdothay.net/blog/2007/08/18/dasBlogV20AndDiscountASPNet.aspx</link>
      <pubDate>Sat, 18 Aug 2007 03:13:06 GMT</pubDate>
      <description>&lt;p&gt;
About a year ago, I attended an MSDN event in my area and won the boobie prize: 12
months of free hosting from an&amp;nbsp;vendor at the event. I had been hosting my site
on my company's web servers, so that seemed like a good opportunity to leave the nest
and test my skills in the wild. Plus, the price was right.
&lt;/p&gt;
&lt;p&gt;
Man, did that suck.
&lt;/p&gt;
&lt;p&gt;
On Wednesday, I&amp;nbsp;signed up for 12 months of hosting with &lt;a href="http://www.discountasp.net/index.aspx"&gt;DiscountASP.Net&lt;/a&gt;.
They advertised on &lt;a href="http://www.asp.net"&gt;www.asp.net&lt;/a&gt;, and had a lot of
good word-of-mouth referrals that eached my ears.
&lt;/p&gt;
&lt;p&gt;
In the matter of about an hour, I did the following:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
Completed an online transaction with DiscountASP.net 
&lt;li&gt;
Accessed my new site through the Control Panel provided by DiscountASP.Net 
&lt;li&gt;
Downloaded the latest &lt;a href="http://dasblog.info/"&gt;dasBlog&lt;/a&gt; bits for ASP.Net
2.0, medium trust 
&lt;li&gt;
Uploaded the dasBlog bits to my new site 
&lt;li&gt;
Switched the DNS servers to my new ISP 
&lt;li&gt;
Moved the content folder from my old host to DiscountASP.Net 
&lt;li&gt;
Minor configuration to secure and customize my blog&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
I'll have you know that I have not yet contacted DiscountASP.Net by phone or e-mail,
nor have I had to read their online help documents. The entire process was smooth
as silk. I was shocked. My previous personal and professional experiences have always
left me in need of some type of resolution.
&lt;/p&gt;
&lt;p&gt;
This is how it should be — DiscountASP.Net has done a great job and I'm grateful.
&lt;/p&gt;
&lt;p&gt;
I was also relieved by the ease of my dasBlog upgrade. I was about a year off the
head in their source code repository. The new version has&amp;nbsp;several sweet skins
out-of-the-box and they're easy to customize. 
&lt;/p&gt;
&lt;p&gt;
I highly recommend dasBlog for any type of blogging solution — it's a rock solid open
source system under active development. Now that I'm 99% out-from-under of my enormous
eight month project, I'd love to saunter over to that open source project and try
my hand at helping the dasBlog&amp;nbsp;dev team. The weekend is just starting,&amp;nbsp;Le
Wife is out of town, and I'm dinking around on a new laptop with Vista. Can't ask
for a better set up than that!
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.andrewdothay.net/blog/aggbug.ashx?id=381983fa-7cf2-4a89-9fa4-d669c33ba0f2" /&gt;</description>
      <comments>http://www.andrewdothay.net/blog/CommentView,guid,381983fa-7cf2-4a89-9fa4-d669c33ba0f2.aspx</comments>
      <category>asp.net</category>
      <category>blogging</category>
      <category>dasBlog</category>
    </item>
    <item>
      <trackback:ping>http://www.andrewdothay.net/blog/Trackback.aspx?guid=baf7f285-def9-4707-a086-9cfc4a7717f0</trackback:ping>
      <pingback:server>http://www.andrewdothay.net/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.andrewdothay.net/blog/PermaLink,guid,baf7f285-def9-4707-a086-9cfc4a7717f0.aspx</pingback:target>
      <dc:creator>Andrew Hay</dc:creator>
      <wfw:comment>http://www.andrewdothay.net/blog/CommentView,guid,baf7f285-def9-4707-a086-9cfc4a7717f0.aspx</wfw:comment>
      <wfw:commentRss>http://www.andrewdothay.net/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=baf7f285-def9-4707-a086-9cfc4a7717f0</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I've been battling some crazy ASP.NET 1.1 code the past couple of days. First, I was
calling some web services with entirely hand written SOAP protocol management. That's
always fun. While tedious and too low of a level to be mucking around, it was the
fastest means to an end with a crotchity ol' Apache/AXIS web service. Even though
I'm fresh off the WCF training regimen; that new stuff wouldn't have helped me here.
Perhaps just having the new stuff in my head pushed me in the right direction
to tackle this challenge - a man can dream, can't he? 
</p>
        <p>
Then, just to rub it in a little, the HTTPWebRequest object decided to give me a swift
kick in the shorts. You see, in .Net 1.1, there's a tiny little unknown (unanswered) bug. 
</p>
        <p>
I have two instance methods and each make a single call over HTTP with their own HTTPWebRequest
object, there's no sharing here. Every time, the second request would hang and throw
a "System.Net.WebException : The operation has timed-out." error. The same code runs
great in .Net 2.0 so I figure its a framework bug. 
</p>
        <p>
I call one method and return a string which is used as an input argument for the second
method. Both calls go to the same top level domain, but call to different end points
on the domain. 
</p>
        <p>
After much thought, trial and error, as well as reading about the same problem other
folks were having, I finally figured out the workaround. 
</p>
        <p>
It turns out that calling the Abort() method on the HTTPRequest instance after completing
the request is sufficient to break up the clog that is preventing subsequent calls.
The following code block shows the working helper method. If I comment out the calll
to Abort(), it no worky. 
</p>
        <pre>private string ExecuteHttpWebRequest(
   string url, RequestMethod method, string message)
{
   HttpWebRequest request = 
      (HttpWebRequest)HttpWebRequest.Create(url);

   request.Timeout = 30000;
   request.KeepAlive = false;
   request.Headers.Add("Cache-Control", "no-cache");
   request.Headers.Add("Pragma", "no-cache");

   switch( method )
   {
      case RequestMethod.Get :

         request.Method = "GET";

         break;

      case RequestMethod.Post :
         
         request.ContentType 
            = "application/x-www-form-urlencoded";
         request.Method = "POST";
         request.ContentLength = message.Length;

         StreamWriter sw = 
            new StreamWriter(request.GetRequestStream());
         sw.Write(message);
         sw.Flush();

         break;
   }

   string html = null;

   using( HttpWebResponse response 
      = (HttpWebResponse)request.GetResponse() )
   {
      Stream rs = response.GetResponseStream();
      StreamReader sr = new StreamReader(rs);
      html = sr.ReadToEnd();
      response.Close();

      // subsequent calls fail without this abort in .Net v1.1
      request.Abort();
   }

   return html;
}	
</pre>
        <img width="0" height="0" src="http://www.andrewdothay.net/blog/aggbug.ashx?id=baf7f285-def9-4707-a086-9cfc4a7717f0" />
      </body>
      <title>System.Net.WebException : The operation has timed-out.</title>
      <guid isPermaLink="false">http://www.andrewdothay.net/blog/PermaLink,guid,baf7f285-def9-4707-a086-9cfc4a7717f0.aspx</guid>
      <link>http://www.andrewdothay.net/blog/2007/07/25/SystemNetWebExceptionTheOperationHasTimedout.aspx</link>
      <pubDate>Wed, 25 Jul 2007 05:27:37 GMT</pubDate>
      <description>&lt;p&gt;
I've been battling some crazy ASP.NET 1.1 code the past couple of days. First, I was
calling some web services with entirely hand written SOAP protocol management. That's
always fun. While tedious and too low of a level to be mucking around, it was the
fastest means to an end with a crotchity ol' Apache/AXIS web service. Even though
I'm fresh off the WCF training regimen; that new stuff wouldn't have helped me here.
Perhaps just having&amp;nbsp;the new stuff in my head pushed me in the right direction
to tackle this challenge - a man can dream, can't he? 
&lt;p&gt;
Then, just to rub it in a little, the HTTPWebRequest object decided to give me a swift
kick in the shorts. You see, in .Net 1.1, there's a tiny little unknown (unanswered)&amp;nbsp;bug. 
&lt;p&gt;
I have two instance methods and each make a single call over HTTP with their own HTTPWebRequest
object, there's no sharing here. Every time, the second request would hang and throw
a "System.Net.WebException : The operation has timed-out." error. The same code runs
great in .Net 2.0 so I figure its a framework bug. 
&lt;p&gt;
I call one method and return a string which is used as an input argument for the second
method. Both calls go to the same top level domain, but call to different end points
on the domain. 
&lt;p&gt;
After much thought, trial and error, as well as reading about the same problem other
folks were having, I finally figured out the workaround. 
&lt;p&gt;
It turns out that calling the Abort() method on the HTTPRequest instance after completing
the request is sufficient to break up the clog that is preventing subsequent calls.
The following code block shows the working helper method. If I comment out the calll
to Abort(), it no worky. &lt;pre&gt;private string ExecuteHttpWebRequest(
   string url, RequestMethod method, string message)
{
   HttpWebRequest request = 
      (HttpWebRequest)HttpWebRequest.Create(url);

   request.Timeout = 30000;
   request.KeepAlive = false;
   request.Headers.Add("Cache-Control", "no-cache");
   request.Headers.Add("Pragma", "no-cache");

   switch( method )
   {
      case RequestMethod.Get :

         request.Method = "GET";

         break;

      case RequestMethod.Post :
         
         request.ContentType 
            = "application/x-www-form-urlencoded";
         request.Method = "POST";
         request.ContentLength = message.Length;

         StreamWriter sw = 
            new StreamWriter(request.GetRequestStream());
         sw.Write(message);
         sw.Flush();

         break;
   }

   string html = null;

   using( HttpWebResponse response 
      = (HttpWebResponse)request.GetResponse() )
   {
      Stream rs = response.GetResponseStream();
      StreamReader sr = new StreamReader(rs);
      html = sr.ReadToEnd();
      response.Close();

      // subsequent calls fail without this abort in .Net v1.1
      request.Abort();
   }

   return html;
}	
&lt;/pre&gt;
&lt;img width="0" height="0" src="http://www.andrewdothay.net/blog/aggbug.ashx?id=baf7f285-def9-4707-a086-9cfc4a7717f0" /&gt;</description>
      <comments>http://www.andrewdothay.net/blog/CommentView,guid,baf7f285-def9-4707-a086-9cfc4a7717f0.aspx</comments>
      <category>asp.net</category>
      <category>popart</category>
      <category>software</category>
    </item>
    <item>
      <trackback:ping>http://www.andrewdothay.net/blog/Trackback.aspx?guid=6e6bfe6d-e2ee-4cfe-bc7b-60a9802993e1</trackback:ping>
      <pingback:server>http://www.andrewdothay.net/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.andrewdothay.net/blog/PermaLink,guid,6e6bfe6d-e2ee-4cfe-bc7b-60a9802993e1.aspx</pingback:target>
      <dc:creator>Andrew Hay</dc:creator>
      <wfw:comment>http://www.andrewdothay.net/blog/CommentView,guid,6e6bfe6d-e2ee-4cfe-bc7b-60a9802993e1.aspx</wfw:comment>
      <wfw:commentRss>http://www.andrewdothay.net/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=6e6bfe6d-e2ee-4cfe-bc7b-60a9802993e1</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <a style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" href="http://www.sliver.com/dotnet/SnippetCompiler/">
          <img style="float: right" alt="Snippet Compiler" hspace="6" src="http://www.andrewdothay.net/blog/content/binary/WindowsLiveWriter/MyFirstLegitUseofSnippetCompiler_134FE/snippetcompiler_7d4925aa-cbf5-4bea-a953-25e5c0d35e3e.png" vspace="6" border="0" />
        </a>
        <p>
Like many of the three of you who subscribe my blog, I download a bunch
of tools &amp; utilities that I read about online and seldom have an opportunity
to use on a real project. 
</p>
        <p>
Today was my first bona fide use of the <a href="http://www.sliver.com/dotnet/SnippetCompiler/" target="_blank">Snippet
Compiler</a> and it just plain rocked. Its a small client application that
can take the place of many throw-away command line programs written just
to test out a concept. The application launches fast and I can start <strong>writing and executing</strong> my
code immediately. I don't need to select a project template, name it, or any
other of the standard housekeeping items. It even has statement completion!
</p>
        <p>
I was working on an existing ASP.Net v1.1 code base for a quick maintenance project.
I gleaned a test order number from the system and quickly realized my
specific test required an <strong>obfuscated</strong> order number from
the following "simple" and "natural" function:
</p>
        <div style="clear: both; background: #000; font: 8pt lucida console, times new roman">
          <p style="color: #00ff00">
//=====================================================================<br />
/// &lt;summary&gt;<br />
///    This method performs exactly the opposite action as<br />
///    EncodeOrderId(), and is meant as the natual companion to that<br />
///    method.  Performs a very simple wrapping bit shift (4 bits
wide,<br />
///    towards the most significant bit) on the input value (unsigned<br />
///    32 bit integer) and returns it as a signed 32 bit integer.<br />
/// &lt;/summary&gt;<br />
/// &lt;param name="orderId"&gt;Value to decode.&lt;/param&gt;<br />
/// &lt;returns&gt;Decoded value.&lt;/returns&gt;<br />
//=====================================================================<br />
public static int DecodeOrderId( uint orderId )<br />
{<br />
   int newOrderId = (int) (( orderId &lt;&lt; 4 ) | ( orderId &gt;&gt; 28
));<br /><br />
   if ( newOrderId &lt; 1 )<br />
   {<br />
      throw( new ArgumentException( "Invalid orderId: '"
+<br />
         orderId.ToString() + "'.", "orderId"
));<br />
   } 
<br /><br />
   return( newOrderId );<br />
} 
</p>
        </div>
        <p>
I was doing integration testing and further more, I was nearly done. I didn't
feel like firing up VS.Net to figure out how to get my test order number obfuscated,
so I thought about it and decided to have a spontaneous moment. 
</p>
        <p>
I (1) fired up the Snippet Compiler, (2) added a reference to the assembly and (3)
wrote a single line of code that called the static method DecodeOrderId() which
wrote the result to the console output. Booya!
</p>
        <img width="0" height="0" src="http://www.andrewdothay.net/blog/aggbug.ashx?id=6e6bfe6d-e2ee-4cfe-bc7b-60a9802993e1" />
      </body>
      <title>My First Legit Use of Snippet Compiler</title>
      <guid isPermaLink="false">http://www.andrewdothay.net/blog/PermaLink,guid,6e6bfe6d-e2ee-4cfe-bc7b-60a9802993e1.aspx</guid>
      <link>http://www.andrewdothay.net/blog/2007/07/06/MyFirstLegitUseOfSnippetCompiler.aspx</link>
      <pubDate>Fri, 06 Jul 2007 05:20:48 GMT</pubDate>
      <description>&lt;a style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" href="http://www.sliver.com/dotnet/SnippetCompiler/"&gt;&lt;img style="float: right" alt="Snippet Compiler" hspace="6" src="http://www.andrewdothay.net/blog/content/binary/WindowsLiveWriter/MyFirstLegitUseofSnippetCompiler_134FE/snippetcompiler_7d4925aa-cbf5-4bea-a953-25e5c0d35e3e.png" vspace="6" border="0"&gt;&lt;/a&gt; 
&lt;p&gt;
Like many of the three of you who&amp;nbsp;subscribe my blog, I download&amp;nbsp;a bunch
of tools &amp;amp; utilities&amp;nbsp;that I&amp;nbsp;read about online and seldom have an opportunity
to use on a real project. 
&lt;/p&gt;
&lt;p&gt;
Today was my first&amp;nbsp;bona fide use of the &lt;a href="http://www.sliver.com/dotnet/SnippetCompiler/" target="_blank"&gt;Snippet
Compiler&lt;/a&gt; and it just plain rocked. Its a&amp;nbsp;small client application&amp;nbsp;that
can take the place of&amp;nbsp;many&amp;nbsp;throw-away command line programs written just
to test out a concept. The application launches&amp;nbsp;fast and I can start &lt;strong&gt;writing&amp;nbsp;and&amp;nbsp;executing&lt;/strong&gt;&amp;nbsp;my
code immediately.&amp;nbsp;I don't need to select a project template, name it, or any
other of the standard housekeeping items. It even has statement completion!
&lt;/p&gt;
&lt;p&gt;
I was working on an existing ASP.Net v1.1 code base for a quick maintenance project.
I gleaned a test&amp;nbsp;order number&amp;nbsp;from the system and&amp;nbsp;quickly realized&amp;nbsp;my
specific test required&amp;nbsp;an &lt;strong&gt;obfuscated&lt;/strong&gt; order number&amp;nbsp;from
the following&amp;nbsp;"simple" and "natural" function:
&lt;/p&gt;
&lt;div style="clear: both; background: #000; font: 8pt lucida console, times new roman"&gt;
&lt;p style="color: #00ff00"&gt;
//=====================================================================&lt;br&gt;
/// &amp;lt;summary&amp;gt;&lt;br&gt;
///&amp;nbsp;&amp;nbsp;&amp;nbsp; This method performs exactly the opposite action as&lt;br&gt;
///&amp;nbsp;&amp;nbsp;&amp;nbsp; EncodeOrderId(), and is meant as the natual companion to that&lt;br&gt;
///&amp;nbsp;&amp;nbsp;&amp;nbsp; method.&amp;nbsp; Performs a very simple wrapping bit shift (4 bits
wide,&lt;br&gt;
///&amp;nbsp;&amp;nbsp;&amp;nbsp; towards the most significant bit) on the input value (unsigned&lt;br&gt;
///&amp;nbsp;&amp;nbsp;&amp;nbsp; 32 bit integer) and returns it as a signed 32 bit integer.&lt;br&gt;
/// &amp;lt;/summary&amp;gt;&lt;br&gt;
/// &amp;lt;param name="orderId"&amp;gt;Value to decode.&amp;lt;/param&amp;gt;&lt;br&gt;
/// &amp;lt;returns&amp;gt;Decoded value.&amp;lt;/returns&amp;gt;&lt;br&gt;
//=====================================================================&lt;br&gt;
public static int DecodeOrderId( uint orderId )&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp; int newOrderId = (int) (( orderId &amp;lt;&amp;lt; 4 ) | ( orderId &amp;gt;&amp;gt; 28
));&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp; if ( newOrderId &amp;lt; 1 )&lt;br&gt;
&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; throw( new ArgumentException( "Invalid orderId: '"
+&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; orderId.ToString() + "'.", "orderId"
));&lt;br&gt;
&amp;nbsp;&amp;nbsp; } 
&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp; return( newOrderId );&lt;br&gt;
} 
&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;
I was doing integration testing and further more, I was nearly done.&amp;nbsp;I didn't
feel like firing up VS.Net&amp;nbsp;to figure out how to get my test order number obfuscated,
so I&amp;nbsp;thought about it and decided to have a spontaneous&amp;nbsp;moment. 
&lt;/p&gt;
&lt;p&gt;
I (1) fired up the Snippet Compiler, (2) added a reference to the assembly and (3)
wrote a single line of code&amp;nbsp;that called the static method DecodeOrderId()&amp;nbsp;which
wrote&amp;nbsp;the result to the console output. Booya!
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.andrewdothay.net/blog/aggbug.ashx?id=6e6bfe6d-e2ee-4cfe-bc7b-60a9802993e1" /&gt;</description>
      <comments>http://www.andrewdothay.net/blog/CommentView,guid,6e6bfe6d-e2ee-4cfe-bc7b-60a9802993e1.aspx</comments>
      <category>asp.net</category>
      <category>Visual Studio</category>
    </item>
    <item>
      <trackback:ping>http://www.andrewdothay.net/blog/Trackback.aspx?guid=94d46088-9e58-4d36-9b7d-83ff299d6581</trackback:ping>
      <pingback:server>http://www.andrewdothay.net/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.andrewdothay.net/blog/PermaLink,guid,94d46088-9e58-4d36-9b7d-83ff299d6581.aspx</pingback:target>
      <dc:creator>Andrew Hay</dc:creator>
      <wfw:comment>http://www.andrewdothay.net/blog/CommentView,guid,94d46088-9e58-4d36-9b7d-83ff299d6581.aspx</wfw:comment>
      <wfw:commentRss>http://www.andrewdothay.net/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=94d46088-9e58-4d36-9b7d-83ff299d6581</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
The <a href="http://pdx.techevents.info/codecamp/3/default.aspx" target="_blank">PDX
Code Camp</a> is next weekend, May 19th and 20th. I've been preparing a talk on how
to <a href="http://pdx.techevents.info/codecamp/3/SessionInfo.aspx?ID=24d5eb46-755c-40ab-806e-93077470b959" target="_blank">create
and use X.509 certificates</a>. Developers need this technology for local testing
of plain old ASP.Net sites, Web Services Enhancements (WSE) or Windows Communication
Foundation (WCF) code. 
</p>
        <p>
The Windows SDK and Visual Studio.Net have some good tools for helping developers
use certificates. I'll show some certificate basics, common examples of certs
in action and tools that help us along the way. My goal is to get the session
attendees comfortable with creating &amp; installing certificates on
their local machine in a variety of code scenarios - that seems like a reasonable
task for a 60 minute presentation and 15 minutes of Q &amp; A.
</p>
        <p>
Just for fun, I worked on a local checkout of <a href="http://code.google.com/p/dotnetopenid/" target="_blank">DotNetOpenID</a> and
implemented SSL for the authentication steps. A lot of the other code in
the presentation is based on the excellent examples from <a href="http://www.dasblonde.net/" target="_blank">Michele
Leroux Bustamante</a>. She does a great job of providing info on these topics for
the developer community.
</p>
        <p>
I have to leave for New London, CT on Sunday so I can only attend one day of this
developer event. Normally, that would suck big time, but I'm also gearing up
for a week long <a href="http://www.idesign.net/idesign/DesktopDefault.aspx?tabindex=0&amp;tabid=20">IDesign
WCF Master Class</a> at <a href="http://training.franklins.net/" target="_blank">Carl
Franklins house</a>. When it rains, it pours!
</p>
        <img width="0" height="0" src="http://www.andrewdothay.net/blog/aggbug.ashx?id=94d46088-9e58-4d36-9b7d-83ff299d6581" />
      </body>
      <title>Portland Code Camp</title>
      <guid isPermaLink="false">http://www.andrewdothay.net/blog/PermaLink,guid,94d46088-9e58-4d36-9b7d-83ff299d6581.aspx</guid>
      <link>http://www.andrewdothay.net/blog/2007/05/14/PortlandCodeCamp.aspx</link>
      <pubDate>Mon, 14 May 2007 05:07:20 GMT</pubDate>
      <description>&lt;p&gt;
The &lt;a href="http://pdx.techevents.info/codecamp/3/default.aspx" target="_blank"&gt;PDX
Code Camp&lt;/a&gt; is next weekend, May 19th and 20th. I've been preparing a talk on how
to &lt;a href="http://pdx.techevents.info/codecamp/3/SessionInfo.aspx?ID=24d5eb46-755c-40ab-806e-93077470b959" target="_blank"&gt;create
and use X.509 certificates&lt;/a&gt;. Developers need this technology for local testing
of&amp;nbsp;plain old&amp;nbsp;ASP.Net sites, Web Services Enhancements (WSE) or Windows Communication
Foundation (WCF) code. 
&lt;/p&gt;
&lt;p&gt;
The Windows SDK and Visual Studio.Net have some good tools for helping developers
use certificates. I'll show some certificate basics,&amp;nbsp;common examples of certs
in&amp;nbsp;action and tools that help us along the way. My goal is to get&amp;nbsp;the session
attendees&amp;nbsp;comfortable with creating&amp;nbsp;&amp;amp; installing certificates&amp;nbsp;on
their local machine in a variety of code scenarios - that seems like a reasonable
task for a 60 minute presentation&amp;nbsp;and 15 minutes of Q &amp;amp; A.
&lt;/p&gt;
&lt;p&gt;
Just for fun, I worked on a local checkout of &lt;a href="http://code.google.com/p/dotnetopenid/" target="_blank"&gt;DotNetOpenID&lt;/a&gt; and
implemented SSL for the&amp;nbsp;authentication steps.&amp;nbsp;A lot of the other code in
the presentation is based on the excellent examples from&amp;nbsp;&lt;a href="http://www.dasblonde.net/" target="_blank"&gt;Michele
Leroux Bustamante&lt;/a&gt;. She does a great job of providing info on these topics for
the developer community.
&lt;/p&gt;
&lt;p&gt;
I have to leave for New London, CT on Sunday so I can only attend one day of this
developer&amp;nbsp;event. Normally, that would suck big time, but I'm also gearing up
for a week long&amp;nbsp;&lt;a href="http://www.idesign.net/idesign/DesktopDefault.aspx?tabindex=0&amp;amp;tabid=20"&gt;IDesign
WCF Master Class&lt;/a&gt; at &lt;a href="http://training.franklins.net/" target="_blank"&gt;Carl
Franklins house&lt;/a&gt;. When it rains, it pours!
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.andrewdothay.net/blog/aggbug.ashx?id=94d46088-9e58-4d36-9b7d-83ff299d6581" /&gt;</description>
      <comments>http://www.andrewdothay.net/blog/CommentView,guid,94d46088-9e58-4d36-9b7d-83ff299d6581.aspx</comments>
      <category>asp.net</category>
      <category>CardSpace</category>
      <category>events</category>
      <category>Visual Studio</category>
    </item>
    <item>
      <trackback:ping>http://www.andrewdothay.net/blog/Trackback.aspx?guid=9e1c8ecf-5f00-4164-ae86-bc74621429b4</trackback:ping>
      <pingback:server>http://www.andrewdothay.net/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.andrewdothay.net/blog/PermaLink,guid,9e1c8ecf-5f00-4164-ae86-bc74621429b4.aspx</pingback:target>
      <dc:creator>Andrew Hay</dc:creator>
      <wfw:comment>http://www.andrewdothay.net/blog/CommentView,guid,9e1c8ecf-5f00-4164-ae86-bc74621429b4.aspx</wfw:comment>
      <wfw:commentRss>http://www.andrewdothay.net/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=9e1c8ecf-5f00-4164-ae86-bc74621429b4</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I recently became aware of the "??" operator in C#. I guess it doesn't have a real
name like the ternary operator that I've long been a fan of using. I'll call it the
WTF operator until I learn a better (more popular) name. Let's take a look at the
"What The <a href="mailto:#$@#%">#$@#%</a>@#" operator in action:
</p>
        <p style="COLOR: #fff; BACKGROUND-COLOR: #666">
        </p>
        <pre>public int PageTabId
{
   get { return Convert.ToInt32(Request.QueryString["PageTabId"] ?? "-1"); }
}</pre>
        <p>
        </p>
        <p>
Per the <a href="http://msdn2.microsoft.com/en-us/library/ms173224.aspx" target="_blank">MSDN
reference</a>, the WTF operator inspects the value on the left side of the "??".
If it's null, the value on the right is returned. If its not null, the value on the
left is returned. Its a lot like IsNull in T-SQL. The code example above is just a
simple helper property for an ASP.Net page. The property looks for a querystring value.
If its there, the value is cast as an integer and returned to the caller. If its not
in the querystring, the default integer value of -1 is returned.
</p>
        <p>
I've been using the ternary operator for a while. Here's the same property as above,
but uses the ternary operator instead. Its more verbose than WTF, but still one line
of code.
</p>
        <p style="COLOR: #fff; BACKGROUND-COLOR: #666">
        </p>
        <pre>public int PageTabId
{
   get 
   { 
      return Request.QueryString["PageTabId"] != null 
         ? Convert.ToInt32( Request.QueryString["PageTabId"] ) : -1; 
   }
}</pre>
        <p>
        </p>
        <p>
I love writing WTF all over my code!
</p>
        <img width="0" height="0" src="http://www.andrewdothay.net/blog/aggbug.ashx?id=9e1c8ecf-5f00-4164-ae86-bc74621429b4" />
      </body>
      <title>C# Operators</title>
      <guid isPermaLink="false">http://www.andrewdothay.net/blog/PermaLink,guid,9e1c8ecf-5f00-4164-ae86-bc74621429b4.aspx</guid>
      <link>http://www.andrewdothay.net/blog/2007/04/01/COperators.aspx</link>
      <pubDate>Sun, 01 Apr 2007 23:29:02 GMT</pubDate>
      <description>&lt;p&gt;
I recently became aware of the "??" operator in C#. I guess it doesn't have a real
name like the ternary operator that I've long been a fan of using. I'll call it the
WTF operator until I learn a better (more popular) name. Let's take a look at the
"What The &lt;a href="mailto:#$@#%"&gt;#$@#%&lt;/a&gt;@#" operator in action:
&lt;/p&gt;
&lt;p style="COLOR: #fff; BACKGROUND-COLOR: #666"&gt;
&lt;pre&gt;public int PageTabId
{
   get { return Convert.ToInt32(Request.QueryString["PageTabId"] ?? "-1"); }
}&lt;/pre&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
Per the &lt;a href="http://msdn2.microsoft.com/en-us/library/ms173224.aspx" target=_blank&gt;MSDN
reference&lt;/a&gt;, the&amp;nbsp;WTF operator inspects the value on the left side of the "??".
If it's null, the value on the right is returned. If its not null, the value on the
left is returned. Its a lot like IsNull in T-SQL. The code example above is just a
simple helper property for an ASP.Net page. The property looks for a querystring value.
If its there, the value is cast as an integer and returned to the caller. If its not
in the querystring, the default integer value of -1 is returned.
&lt;/p&gt;
&lt;p&gt;
I've been using the ternary operator for a while. Here's the same property as above,
but uses the ternary operator instead. Its more verbose than WTF, but still one line
of code.
&lt;/p&gt;
&lt;p style="COLOR: #fff; BACKGROUND-COLOR: #666"&gt;
&lt;pre&gt;public int PageTabId
{
   get 
   { 
      return Request.QueryString["PageTabId"] != null 
         ? Convert.ToInt32( Request.QueryString["PageTabId"] ) : -1; 
   }
}&lt;/pre&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
I love writing WTF all over my code!
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.andrewdothay.net/blog/aggbug.ashx?id=9e1c8ecf-5f00-4164-ae86-bc74621429b4" /&gt;</description>
      <comments>http://www.andrewdothay.net/blog/CommentView,guid,9e1c8ecf-5f00-4164-ae86-bc74621429b4.aspx</comments>
      <category>asp.net</category>
      <category>learning</category>
    </item>
    <item>
      <trackback:ping>http://www.andrewdothay.net/blog/Trackback.aspx?guid=a802161d-8f36-480d-b56d-f9151b3d87aa</trackback:ping>
      <pingback:server>http://www.andrewdothay.net/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.andrewdothay.net/blog/PermaLink,guid,a802161d-8f36-480d-b56d-f9151b3d87aa.aspx</pingback:target>
      <dc:creator>Andrew Hay</dc:creator>
      <wfw:comment>http://www.andrewdothay.net/blog/CommentView,guid,a802161d-8f36-480d-b56d-f9151b3d87aa.aspx</wfw:comment>
      <wfw:commentRss>http://www.andrewdothay.net/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=a802161d-8f36-480d-b56d-f9151b3d87aa</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <img style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; MARGIN: 0px 25px 10px 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="200" src="http://www.andrewdothay.net/blog/content/binary/WindowsLiveWriter/CardSpacetheLawsofIdentity_B37A/sao-devsig-cardspace-openid%5B2%5D.jpg" width="250" align="left" border="0" /> I
attended the Software Association of Oregon (SAO) event today. The Development
Special Interest Group (DEV SIG) hosted a discussion about Microsoft CardSpace, the
open source framework of OpenID, and basic identity management.
</p>
        <p>
Stuart Celarier walked the audience through <a href="http://www.identityblog.com/" target="_blank">Kim
Cameron's</a> paper called <a href="http://www.identityblog.com/?page_id=354" target="_blank">The
Laws of Identity</a> that articulate seven desired aspects of a good identity
system.
</p>
        <p>
Microsoft CardSpace was formerly named "InfoCard". This is a joint effort to implement
the identity metasystem defined by the laws of identity. CardSpace is the "identity
selector" for Windows. It needs IE7 and Microsoft .Net Framework 3.0 to operate. It implements
the WS-* specifications in this service.
</p>
        <p>
          <a href="http://osis.netmesh.org/" target="_blank">OSIS - Open Source Identity System</a>:
This is an open source group that's involved in the identity space.
</p>
        <p>
Stuart also showed a demo of a system he's been working on. It logs a user into Wachovia
banking site using CardSpace.  Scott Kveton of <a href="http://janrain.com/" target="_blank">JANRAIN</a> presented
OpenID to the SAO DEV SIG group. OpenID hopes to solve the problem of having too many
usernames and passwords. 
</p>
        <ul>
          <li>
Single Signon for the web 
</li>
          <li>
Simple, light-weight 
</li>
          <li>
Easy to use, easy to deploy 
</li>
          <li>
Open development process 
</li>
          <li>
Decentralized</li>
        </ul>
        <p>
Your OpenID is a URL: <a title="http://kveton.myopenid.com/" href="http://kveton.myopenid.com/">http://kveton.myopenid.com/</a></p>
        <ul>
          <li>
OpenID comes from the blogosphere 
</li>
          <li>
Biggest problem with identity; namespace 
</li>
          <li>
OpenID solves this by using DNS 
</li>
          <li>
Your identity is a destination 
</li>
          <li>
You have a unique endpoint on the web</li>
        </ul>
        <p>
Scott Kveton explained how sites enabled with OpenID enable users to authenticate.
Visitors type in their OpenID, and the browser redirects to your OpenID provider.
The visitor makes the appropriate decision and the browser redirects back the website.
</p>
        <p>
Scott's site is <a href="http://scott.kveton.com">http://scott.kveton.com</a></p>
        <p>
Last week Bill Gates announced support for OpenID. AOL announced support for OpenID
this morning. More companies are about to make similar announcments. Here's some interesting
stats on adoption:
</p>
        <ul>
          <li>
12-15 million users with OpenIDs. 
</li>
          <li>
1000+ OpenID enabled sites 
</li>
          <li>
10-15 new OpenID enabled sites each day 
</li>
          <li>
7% grown each week with new sites</li>
        </ul>
        <p>
Kveton also brought up "Microformats" - a way to describe data in an HTML format (contact
info, social network, calendar). These can be embedded on pages. There are some interesting
ways to use OpenID with these technologies:
</p>
        <ul>
          <li>
OpenID + iCal 
</li>
          <li>
OpenID + hCards 
</li>
          <li>
OpenID + Social Networking (XFN, FOAP or FOAF?) 
</li>
          <li>
OpenId + Reputation (jyte.com)</li>
        </ul>
        <p>
OpenID Predictions from Kveton:
</p>
        <ul>
          <li>
7500 sites supporting OpenID 
</li>
          <li>
100 million users with OpenID 
</li>
          <li>
Big players adopt OpenID</li>
        </ul>
        <p>
OpenID.net has a ton of info.
</p>
        <p>
Scott Hanselman explained how he enabled OpenID on his blog. Hte added two HTML
&lt;link&gt; tags to his website. <a href="http://simonwillison.net/" target="_blank">Simon
Willison</a> has an OpenID enabled blog. A visitor can click Sign in with OpenID.
The OpenID logo lives inside the textbox. Scott entered his OpenID in the textbox
on Simon's site. Using a web service, Simon's blog discovered Hanselman's
OpenID provider, then it redirected the browser to Scott's OpenID provider. 
</p>
        <p>
Scott's website indicates the OpenID provider is <a href="http://www.myopenid.com">www.myopenid.com</a>. 
</p>
        <p>
The OpenID provider prompts Scott to authenticate. After a successful login,
the browser redirects back to Simon's page and recogizes Scott Hanselman. This is
how Simon doesn't need to keep track of usernames and passwords for his blog; <font size="5">a
huge benefit.</font></p>
        <p>
Stuart helped explain the difference between self-insued cards and managed cards:
Business Cards from Kinko's versus a card issued from Visa.
</p>
        <p>
Scott Hanselman displayed a different identity selector using Firefox on Windows.
The page contains an HTML &lt;object&gt; tag of type "application/x-informationCard".
It wasn't as pretty as the CardSpace in IE7 and .Net 3.0, but it had the same behavior.
</p>
        <p>
There was some last minute discusson on "I-Name", an XRI technology (extensible
resource identifier). It sounds like its still being baked.
</p>
        <p>
2idi relays comments on Scott's blog. They will issue an I-Name. =kveton is Scott's
I-Name. They have an DNS resolver where visitors may enter xri://=scott.hanselman/photo
to redirect to his Flickr account.
</p>
        <img width="0" height="0" src="http://www.andrewdothay.net/blog/aggbug.ashx?id=a802161d-8f36-480d-b56d-f9151b3d87aa" />
      </body>
      <title>CardSpace &amp;amp; the Laws of Identity</title>
      <guid isPermaLink="false">http://www.andrewdothay.net/blog/PermaLink,guid,a802161d-8f36-480d-b56d-f9151b3d87aa.aspx</guid>
      <link>http://www.andrewdothay.net/blog/2007/02/16/CardSpaceAmpTheLawsOfIdentity.aspx</link>
      <pubDate>Fri, 16 Feb 2007 00:47:54 GMT</pubDate>
      <description>&lt;p&gt;
&lt;img style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; MARGIN: 0px 25px 10px 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=200 src="http://www.andrewdothay.net/blog/content/binary/WindowsLiveWriter/CardSpacetheLawsofIdentity_B37A/sao-devsig-cardspace-openid%5B2%5D.jpg" width=250 align=left border=0&gt; I
attended the Software Association of Oregon (SAO)&amp;nbsp;event today. The Development
Special Interest Group (DEV SIG) hosted a discussion about Microsoft CardSpace, the
open source framework of OpenID, and basic identity management.
&lt;/p&gt;
&lt;p&gt;
Stuart Celarier walked the audience through &lt;a href="http://www.identityblog.com/" target=_blank&gt;Kim
Cameron's&lt;/a&gt; paper called &lt;a href="http://www.identityblog.com/?page_id=354" target=_blank&gt;The
Laws of Identity&lt;/a&gt;&amp;nbsp;that articulate seven desired aspects of a good identity
system.
&lt;/p&gt;
&lt;p&gt;
Microsoft CardSpace was formerly named "InfoCard". This is a joint effort to implement
the identity metasystem defined by the laws of identity. CardSpace is the "identity
selector" for Windows. It needs IE7 and Microsoft .Net Framework 3.0 to operate. It&amp;nbsp;implements
the WS-* specifications in this service.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://osis.netmesh.org/" target=_blank&gt;OSIS - Open Source Identity System&lt;/a&gt;:
This is an open source&amp;nbsp;group that's involved in the identity space.
&lt;/p&gt;
&lt;p&gt;
Stuart also showed a demo of a system he's been working on. It logs a user into Wachovia
banking site using CardSpace.&amp;nbsp; Scott Kveton of&amp;nbsp;&lt;a href="http://janrain.com/" target=_blank&gt;JANRAIN&lt;/a&gt; presented
OpenID to the SAO DEV SIG group. OpenID hopes to solve the problem of having too many
usernames and passwords. 
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
Single Signon for the web 
&lt;li&gt;
Simple, light-weight 
&lt;li&gt;
Easy to use, easy to deploy 
&lt;li&gt;
Open development process 
&lt;li&gt;
Decentralized&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
Your OpenID is a URL: &lt;a title=http://kveton.myopenid.com/ href="http://kveton.myopenid.com/"&gt;http://kveton.myopenid.com/&lt;/a&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
OpenID comes from the blogosphere 
&lt;li&gt;
Biggest problem with identity; namespace 
&lt;li&gt;
OpenID solves this by using DNS 
&lt;li&gt;
Your identity is a destination 
&lt;li&gt;
You have a unique endpoint on the web&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
Scott Kveton explained how sites enabled with OpenID enable users to authenticate.
Visitors type in their OpenID, and the browser redirects to your OpenID provider.
The visitor makes the appropriate decision and the browser redirects back the website.
&lt;/p&gt;
&lt;p&gt;
Scott's site is &lt;a href="http://scott.kveton.com"&gt;http://scott.kveton.com&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
Last week Bill Gates announced support for OpenID. AOL announced support for OpenID
this morning. More companies are about to make similar announcments. Here's some interesting
stats on adoption:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
12-15 million users with OpenIDs. 
&lt;li&gt;
1000+ OpenID enabled sites 
&lt;li&gt;
10-15 new OpenID enabled sites each day 
&lt;li&gt;
7% grown each week with new sites&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
Kveton also brought up "Microformats" - a way to describe data in an HTML format (contact
info, social network, calendar). These can be embedded on pages. There are some interesting
ways to use OpenID with these technologies:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
OpenID + iCal 
&lt;li&gt;
OpenID + hCards 
&lt;li&gt;
OpenID + Social Networking (XFN, FOAP or FOAF?) 
&lt;li&gt;
OpenId + Reputation (jyte.com)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
OpenID Predictions from Kveton:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
7500 sites supporting OpenID 
&lt;li&gt;
100 million users with OpenID 
&lt;li&gt;
Big players adopt OpenID&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
OpenID.net has a ton of info.
&lt;/p&gt;
&lt;p&gt;
Scott Hanselman&amp;nbsp;explained how he enabled OpenID on his blog. Hte added two HTML
&amp;lt;link&amp;gt; tags to his website. &lt;a href="http://simonwillison.net/" target=_blank&gt;Simon
Willison&lt;/a&gt; has an OpenID enabled blog. A visitor can click Sign in with OpenID.
The OpenID logo lives inside the textbox. Scott entered his OpenID in the textbox
on Simon's site.&amp;nbsp;Using a web service, Simon's blog&amp;nbsp;discovered&amp;nbsp;Hanselman's
OpenID&amp;nbsp;provider, then it&amp;nbsp;redirected the browser to Scott's OpenID provider. 
&lt;/p&gt;
&lt;p&gt;
Scott's&amp;nbsp;website indicates the OpenID provider is &lt;a href="http://www.myopenid.com"&gt;www.myopenid.com&lt;/a&gt;.&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
The OpenID provider&amp;nbsp;prompts&amp;nbsp;Scott to authenticate. After a successful login,
the browser redirects back to Simon's page and recogizes Scott Hanselman. This is
how Simon doesn't need to keep track of usernames and passwords for his blog; &lt;font size=5&gt;a
huge benefit.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
Stuart helped explain the difference between self-insued cards and managed cards:
Business Cards from Kinko's versus a card issued from Visa.
&lt;/p&gt;
&lt;p&gt;
Scott Hanselman displayed a different identity selector using Firefox on Windows.
The page contains an HTML &amp;lt;object&amp;gt; tag&amp;nbsp;of type "application/x-informationCard".
It wasn't as pretty as the CardSpace in IE7 and .Net 3.0, but it had the same behavior.
&lt;/p&gt;
&lt;p&gt;
There was some last minute discusson on&amp;nbsp;"I-Name",&amp;nbsp;an XRI technology (extensible
resource identifier). It sounds like its still being baked.
&lt;/p&gt;
&lt;p&gt;
2idi&amp;nbsp;relays comments on Scott's blog. They will issue an I-Name. =kveton is Scott's
I-Name. They have an DNS resolver where visitors may enter xri://=scott.hanselman/photo
to redirect to his Flickr account.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.andrewdothay.net/blog/aggbug.ashx?id=a802161d-8f36-480d-b56d-f9151b3d87aa" /&gt;</description>
      <comments>http://www.andrewdothay.net/blog/CommentView,guid,a802161d-8f36-480d-b56d-f9151b3d87aa.aspx</comments>
      <category>asp.net</category>
      <category>blogging</category>
      <category>events</category>
      <category>ie7</category>
      <category>learning</category>
      <category>software</category>
      <category>CardSpace</category>
    </item>
    <item>
      <trackback:ping>http://www.andrewdothay.net/blog/Trackback.aspx?guid=c670602b-ffcb-4002-bcae-d4ff1af85aa7</trackback:ping>
      <pingback:server>http://www.andrewdothay.net/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.andrewdothay.net/blog/PermaLink,guid,c670602b-ffcb-4002-bcae-d4ff1af85aa7.aspx</pingback:target>
      <dc:creator>Andrew Hay</dc:creator>
      <wfw:comment>http://www.andrewdothay.net/blog/CommentView,guid,c670602b-ffcb-4002-bcae-d4ff1af85aa7.aspx</wfw:comment>
      <wfw:commentRss>http://www.andrewdothay.net/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=c670602b-ffcb-4002-bcae-d4ff1af85aa7</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I was accepted to speak at the next Code Camp, the weekend of Oct 28th, in
Seattle! Hooray!! I thought for a little bit on (A) what would be a fun topic
and (2) what do I have to say about said fun topic. I finally settled on talking about <a href="http://seattle.techevents.info/codecamp/2/PresenterInfo.aspx?ID=42f50129-5d63-4818-9cdc-9d40a19ba22f" target="_blank">something
I do on a daily basis</a>: balancing the needs of the web designer, leveraging sufficient
power of a great platform (read that as using the base class libraries and everything
else given to me), along with the needs of the client and the overall budget.
</p>
        <p>
Our designers at Pop Art are top shelf. They've come up with some fantastic ideas
for sites. They're on the leading edge of what's possible with today's browsers and
giving consideration to the downlevel browser folk.
</p>
        <p>
Given that, they have some high demands on the HTML emitted by anything on the server.
It absolutely, positively must be W3C compliant. It doesn't matter if its HTML 4.01
Transitional, or HTML 1.0 Strict; so long as it conforms to the given specification.
Gone are the days of using menu server controls that emitted glorious reams of &lt;table&gt;,
&lt;tr&gt; and &lt;td&gt; tags. Enough for you to knit a small blanket. Amen for the <a href="http://weblogs.asp.net/scottgu/archive/2006/09/08/CSS-Control-Adapter-Toolkit-Update.aspx">CSS
Control Adapters</a>. 
</p>
        <p>
The designers have a lot to say on usability too. There are just some things that
developers will step right over like a country boy; where as the country boy's college
roommate visiting for the weekend will stop, stare, point, hold their nose
and give it a wide birth.
</p>
        <p>
Enter DotNetNuke. Out-of-the-box, DNN is a developers playground. They know there's
so much capability under the hood that they're (and I'm generalizing here) too busy
envisioning what they're going to build next instead of rethinking the user interface
that a client would need to maintain a site. That seems like small potatoes next to
the glorious reams of code we can write.
</p>
        <p>
So, I've settled on presenting the issues, challenges, arguments, counter-points and
three-point-takedowns that we've had to address over the past 18 months with
DNN. That would be a little too gloomy, so the remaining 67% of the discussion will contain some
solutions that bridge the gap and keep the web site looking beautiful long after it
launches. My presentation is in no way the rule; simply my experiences in dealing
with this issue since I came to Pop Art in 2002. As with most things, I'm sure they
are lots of ways to handle them, and I'm as open minded as the next guy; providing
the next guy is sans jerk.
</p>
        <p>
A basic introduction of DotNetNuke would be better served by a different session,
but people who've never downloaded the bits from <a href="http://www.dotnetnuke.com">www.dotnetnuke.com</a> will
still get a reasonable insight into the problem sets and ways to deal with them.
</p>
        <p>
My basic fear is probably the same as any other presenter who ever presented in all
of presentation-land: getting slotted in the same time slot as ScottGu or anyone else
in the rock star line up. What a problem to have!!   :)
</p>
        <img width="0" height="0" src="http://www.andrewdothay.net/blog/aggbug.ashx?id=c670602b-ffcb-4002-bcae-d4ff1af85aa7" />
      </body>
      <title>Presenting at Seattle Code Camp</title>
      <guid isPermaLink="false">http://www.andrewdothay.net/blog/PermaLink,guid,c670602b-ffcb-4002-bcae-d4ff1af85aa7.aspx</guid>
      <link>http://www.andrewdothay.net/blog/2006/10/15/PresentingAtSeattleCodeCamp.aspx</link>
      <pubDate>Sun, 15 Oct 2006 15:35:33 GMT</pubDate>
      <description>&lt;p&gt;
I was accepted to speak at the next Code Camp,&amp;nbsp;the weekend of Oct 28th,&amp;nbsp;in
Seattle! Hooray!!&amp;nbsp;I thought for a little bit on (A) what would be a fun topic
and (2) what do I have to say about said fun topic. I finally settled on talking about&amp;nbsp;&lt;a href="http://seattle.techevents.info/codecamp/2/PresenterInfo.aspx?ID=42f50129-5d63-4818-9cdc-9d40a19ba22f" target=_blank&gt;something
I do on a daily basis&lt;/a&gt;: balancing the needs of the web designer, leveraging&amp;nbsp;sufficient
power of a great platform (read that as using the base class libraries and everything
else given to me), along with the needs of the client and the overall budget.
&lt;/p&gt;
&lt;p&gt;
Our designers at Pop Art are top shelf. They've come up with some fantastic ideas
for sites. They're on the leading edge of what's possible with today's browsers and
giving consideration to the downlevel browser folk.
&lt;/p&gt;
&lt;p&gt;
Given that, they have some high demands on the HTML emitted by anything on the server.
It absolutely, positively must be W3C compliant. It doesn't matter if its HTML 4.01
Transitional, or HTML 1.0 Strict; so long as it conforms to the given specification.
Gone are the days of using menu server controls that emitted glorious reams of &amp;lt;table&amp;gt;,
&amp;lt;tr&amp;gt; and &amp;lt;td&amp;gt; tags. Enough for you to knit a small blanket. Amen for the &lt;a href="http://weblogs.asp.net/scottgu/archive/2006/09/08/CSS-Control-Adapter-Toolkit-Update.aspx"&gt;CSS
Control Adapters&lt;/a&gt;. 
&lt;/p&gt;
&lt;p&gt;
The designers have a lot to say on usability too. There are just some things that
developers will step right over like a country boy; where as the&amp;nbsp;country boy's&amp;nbsp;college
roommate&amp;nbsp;visiting&amp;nbsp;for the weekend will stop, stare, point, hold their nose
and give it a wide birth.
&lt;/p&gt;
&lt;p&gt;
Enter DotNetNuke. Out-of-the-box, DNN is a developers playground. They know there's
so much capability under the hood that they're (and I'm generalizing here) too busy
envisioning what they're going to build next instead of rethinking the user interface
that a client would need to maintain a site. That seems like small potatoes next to
the glorious reams of code we can write.
&lt;/p&gt;
&lt;p&gt;
So, I've settled on presenting the issues, challenges, arguments, counter-points and
three-point-takedowns&amp;nbsp;that we've had to address over the past 18 months with
DNN. That would be a little too gloomy, so the remaining 67% of the discussion will&amp;nbsp;contain&amp;nbsp;some
solutions that bridge the gap and keep the web site looking beautiful long after it
launches. My presentation is in no way the rule; simply my experiences in dealing
with this issue since I came to Pop Art in 2002. As with most things, I'm sure they
are lots of ways to handle them, and I'm as open minded as the next guy; providing
the next guy is sans jerk.
&lt;/p&gt;
&lt;p&gt;
A basic introduction of DotNetNuke would be better served by a different session,
but people who've never downloaded the bits from &lt;a href="http://www.dotnetnuke.com"&gt;www.dotnetnuke.com&lt;/a&gt; will
still get a reasonable insight into the problem sets and&amp;nbsp;ways to deal with them.
&lt;/p&gt;
&lt;p&gt;
My basic fear is probably the same as any other presenter who ever presented in all
of presentation-land: getting slotted in the same time slot as ScottGu or anyone&amp;nbsp;else
in the&amp;nbsp;rock star line up. What a problem to have!!&amp;nbsp;&amp;nbsp; :)
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.andrewdothay.net/blog/aggbug.ashx?id=c670602b-ffcb-4002-bcae-d4ff1af85aa7" /&gt;</description>
      <comments>http://www.andrewdothay.net/blog/CommentView,guid,c670602b-ffcb-4002-bcae-d4ff1af85aa7.aspx</comments>
      <category>asp.net</category>
      <category>DotNetNuke</category>
      <category>events</category>
      <category>learning</category>
      <category>popart</category>
    </item>
    <item>
      <trackback:ping>http://www.andrewdothay.net/blog/Trackback.aspx?guid=c57c27b2-32fe-44a4-837d-947f90434707</trackback:ping>
      <pingback:server>http://www.andrewdothay.net/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.andrewdothay.net/blog/PermaLink,guid,c57c27b2-32fe-44a4-837d-947f90434707.aspx</pingback:target>
      <dc:creator>Andrew Hay</dc:creator>
      <wfw:comment>http://www.andrewdothay.net/blog/CommentView,guid,c57c27b2-32fe-44a4-837d-947f90434707.aspx</wfw:comment>
      <wfw:commentRss>http://www.andrewdothay.net/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=c57c27b2-32fe-44a4-837d-947f90434707</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I heard that <a href="http://dotnetnuke.com/Development/ReleaseSchedule/tabid/944/Default.aspx">DNN
4.3.5</a> is due out shortly. Its a stabilization release, so don't look for new features. <a href="http://kelly.staging.popart.com/PermaLink,guid,b9563b0d-2382-4ca3-b55b-23a6277d3e85.aspx">Kelly
submitted a bug fix</a> to them yesterday and was concerned about the complexity.
I can imagine the core team is so close to the system that they can't see the difficultly
that new recruits would have in understanding this organization and contributing.
I told Kelly that perhaps he and I can write a Wrox Press book on how to contribute
to the DNN source!
</p>
        <img width="0" height="0" src="http://www.andrewdothay.net/blog/aggbug.ashx?id=c57c27b2-32fe-44a4-837d-947f90434707" />
      </body>
      <title>DNN 4.3.5 Coming Soon</title>
      <guid isPermaLink="false">http://www.andrewdothay.net/blog/PermaLink,guid,c57c27b2-32fe-44a4-837d-947f90434707.aspx</guid>
      <link>http://www.andrewdothay.net/blog/2006/09/12/DNN435ComingSoon.aspx</link>
      <pubDate>Tue, 12 Sep 2006 17:15:42 GMT</pubDate>
      <description>&lt;p&gt;
I heard that &lt;a href="http://dotnetnuke.com/Development/ReleaseSchedule/tabid/944/Default.aspx"&gt;DNN
4.3.5&lt;/a&gt; is due out shortly. Its a stabilization release, so don't look for new features. &lt;a href="http://kelly.staging.popart.com/PermaLink,guid,b9563b0d-2382-4ca3-b55b-23a6277d3e85.aspx"&gt;Kelly
submitted a bug fix&lt;/a&gt; to them yesterday and was concerned about the complexity.
I can imagine the core team is so close to the system that they can't see the difficultly
that new recruits would have in understanding this organization and contributing.
I told Kelly that perhaps he and I can write a Wrox Press book on how to contribute
to the DNN source!
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.andrewdothay.net/blog/aggbug.ashx?id=c57c27b2-32fe-44a4-837d-947f90434707" /&gt;</description>
      <comments>http://www.andrewdothay.net/blog/CommentView,guid,c57c27b2-32fe-44a4-837d-947f90434707.aspx</comments>
      <category>asp.net</category>
      <category>DotNetNuke</category>
      <category>popart</category>
    </item>
    <item>
      <trackback:ping>http://www.andrewdothay.net/blog/Trackback.aspx?guid=af8a4c8f-8b2d-4489-98c9-bfe88f198ea5</trackback:ping>
      <pingback:server>http://www.andrewdothay.net/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.andrewdothay.net/blog/PermaLink,guid,af8a4c8f-8b2d-4489-98c9-bfe88f198ea5.aspx</pingback:target>
      <dc:creator>Andrew Hay</dc:creator>
      <wfw:comment>http://www.andrewdothay.net/blog/CommentView,guid,af8a4c8f-8b2d-4489-98c9-bfe88f198ea5.aspx</wfw:comment>
      <wfw:commentRss>http://www.andrewdothay.net/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=af8a4c8f-8b2d-4489-98c9-bfe88f198ea5</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
This very short little console program I wrote the other day was giving me grief.
I'm validating some URLs for HTML compliance as part of our continuous integration
system. Everytime some code is checked into Subversion, we make sure the pages are
XHTML 1.0 Strict compliant.
</p>
        <p>
I'm simply sending an HTTPRequest post to <a href="http://validator.w3.org/check">http://validator.w3.org/check</a> and
passing the HTML I pull off of a URL in the project. For some reason, the validator
didn't like the semi-colon characters that were part of some in-line styles. 
</p>
        <p>
          <em>Yes, I know in-line styles should be avoided, but we're talking about something
else here for a minute, ok? So, focus.</em>
        </p>
        <p>
The validator said I should be encoding these entity references. Something wasn't
just feeling quite right, and then it hit me while I was sipping my morning coffee
on my sofa: Andrew, you forgot to set the content type and Url Encode the payload
of the post. Drat!! I know how to do this! My eyes kept skipping over the problem
though in this tiny program. 
</p>
        <p>
To add to the problem, I didn't ask anyone over to my desk last week either.
I'm sure they would have spotted it right away. For some reason I was convinced the
problem was much cooler, deeper or otherwise time consuming to bother my crew. That
was my second mistake. 
</p>
        <p>
So, I'm looking at it with fresh, well, bleary, eyes this Saturday morning. As
I look at the now functional code, I'm thinking about refactoring it along with some
unit tests. Its interesting to think about how I would have written this program differently
under a test driven development style. It would have been much less procedural and
more object oriented, to be sure. 
</p>
        <p>
Here's the snippet of what was getting my goat the end of this week at work: 
</p>
        <p>
          <code>
            <font size="1">HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(_VALIDATION_URL);<br />
webRequest.CookieContainer = new CookieContainer();<br /><font color="red">string postContent = "fragment=" + HttpUtility.UrlEncode(html);</font><br />
byte[] postBuffer = new UTF8Encoding().GetBytes(postContent);<br />
webRequest.Method = "POST";<br /><font color="red">webRequest.ContentType = "application/x-www-form-urlencoded";</font><br />
webRequest.ContentLength = postBuffer.Length;<br />
Stream requestStream = webRequest.GetRequestStream();<br />
requestStream.Write(postBuffer, 0, postBuffer.Length);<br />
requestStream.Close();<br />
HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse();<br />
StreamReader sr = new StreamReader(webResponse.GetResponseStream(), Encoding.UTF8);</font>
            <br />
          </code>
        </p>
        <img width="0" height="0" src="http://www.andrewdothay.net/blog/aggbug.ashx?id=af8a4c8f-8b2d-4489-98c9-bfe88f198ea5" />
      </body>
      <title>Flippin Encodings!</title>
      <guid isPermaLink="false">http://www.andrewdothay.net/blog/PermaLink,guid,af8a4c8f-8b2d-4489-98c9-bfe88f198ea5.aspx</guid>
      <link>http://www.andrewdothay.net/blog/2006/09/02/FlippinEncodings.aspx</link>
      <pubDate>Sat, 02 Sep 2006 18:15:35 GMT</pubDate>
      <description>&lt;p&gt;
This very short little console program I wrote the other day was giving me grief.
I'm validating some URLs for HTML compliance as part of our continuous integration
system. Everytime some code is checked into Subversion, we make sure the pages are
XHTML 1.0 Strict compliant.
&lt;/p&gt;
&lt;p&gt;
I'm simply sending an HTTPRequest post to &lt;a href="http://validator.w3.org/check"&gt;http://validator.w3.org/check&lt;/a&gt; and
passing the HTML I pull off of a URL in the project. For some reason, the validator
didn't like the semi-colon characters that were part of some in-line styles. 
&lt;p&gt;
&lt;em&gt;Yes, I know in-line styles should be avoided, but we're talking about something
else here for a minute, ok? So, focus.&lt;/em&gt; 
&lt;p&gt;
The validator said I should be encoding these entity references. Something wasn't
just feeling quite right, and then it hit me while I was sipping my morning coffee
on my sofa: Andrew, you forgot to set the content type and Url Encode the payload
of the post. Drat!! I know how to do this! My eyes kept skipping over the problem
though in this tiny program. 
&lt;p&gt;
To add to the problem, I didn't ask anyone over to my desk last week&amp;nbsp;either.
I'm sure they would have spotted it right away. For some reason I was convinced the
problem was much cooler, deeper or otherwise time consuming to bother my crew. That
was my second mistake. 
&lt;p&gt;
So, I'm looking at it with fresh, well, bleary, eyes&amp;nbsp;this Saturday morning. As
I look at the now functional code, I'm thinking about refactoring it along with some
unit tests. Its interesting to think about how I would have written this program differently
under a test driven development style. It would have been much less procedural and
more object oriented, to be sure. 
&lt;p&gt;
Here's the snippet of what was getting my goat the end of this week at work: 
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;&lt;font size=1&gt;HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(_VALIDATION_URL);&lt;br&gt;
webRequest.CookieContainer = new CookieContainer();&lt;br&gt;
&lt;font color=red&gt;string postContent = "fragment=" + HttpUtility.UrlEncode(html);&lt;/font&gt;
&lt;br&gt;
byte[] postBuffer = new UTF8Encoding().GetBytes(postContent);&lt;br&gt;
webRequest.Method = "POST";&lt;br&gt;
&lt;font color=red&gt;webRequest.ContentType = "application/x-www-form-urlencoded";&lt;/font&gt;
&lt;br&gt;
webRequest.ContentLength = postBuffer.Length;&lt;br&gt;
Stream requestStream = webRequest.GetRequestStream();&lt;br&gt;
requestStream.Write(postBuffer, 0, postBuffer.Length);&lt;br&gt;
requestStream.Close();&lt;br&gt;
HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse();&lt;br&gt;
StreamReader sr = new StreamReader(webResponse.GetResponseStream(), Encoding.UTF8);&lt;/font&gt;
&lt;br&gt;
&lt;/code&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.andrewdothay.net/blog/aggbug.ashx?id=af8a4c8f-8b2d-4489-98c9-bfe88f198ea5" /&gt;</description>
      <comments>http://www.andrewdothay.net/blog/CommentView,guid,af8a4c8f-8b2d-4489-98c9-bfe88f198ea5.aspx</comments>
      <category>asp.net</category>
    </item>
    <item>
      <trackback:ping>http://www.andrewdothay.net/blog/Trackback.aspx?guid=ae037fa1-12a9-4b21-b9aa-9800aeff38d7</trackback:ping>
      <pingback:server>http://www.andrewdothay.net/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.andrewdothay.net/blog/PermaLink,guid,ae037fa1-12a9-4b21-b9aa-9800aeff38d7.aspx</pingback:target>
      <dc:creator>Andrew Hay</dc:creator>
      <wfw:comment>http://www.andrewdothay.net/blog/CommentView,guid,ae037fa1-12a9-4b21-b9aa-9800aeff38d7.aspx</wfw:comment>
      <wfw:commentRss>http://www.andrewdothay.net/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=ae037fa1-12a9-4b21-b9aa-9800aeff38d7</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I attended a recent <a href="http://msdn.microsoft.com/events/">MSDN Event</a> and won
a free one year hosting contract at <a href="http://www.hosting.com">www.hosting.com</a>. 
</p>
        <p>
After a little wrangling, I pack up my dasBlog satchel and moved into the new digs.
Time to buy some new drapes and check out the neighborhood. I hope the local video
store has a good selection. I'll have to say goodbye to my (paultry) Google rankings,
for a little while at least.
</p>
        <img width="0" height="0" src="http://www.andrewdothay.net/blog/aggbug.ashx?id=ae037fa1-12a9-4b21-b9aa-9800aeff38d7" />
      </body>
      <title>This site has moved</title>
      <guid isPermaLink="false">http://www.andrewdothay.net/blog/PermaLink,guid,ae037fa1-12a9-4b21-b9aa-9800aeff38d7.aspx</guid>
      <link>http://www.andrewdothay.net/blog/2006/08/22/ThisSiteHasMoved.aspx</link>
      <pubDate>Tue, 22 Aug 2006 20:32:53 GMT</pubDate>
      <description>&lt;p&gt;
I attended a recent &lt;a href="http://msdn.microsoft.com/events/"&gt;MSDN Event&lt;/a&gt; and&amp;nbsp;won
a free one year hosting contract at &lt;a href="http://www.hosting.com"&gt;www.hosting.com&lt;/a&gt;. 
&lt;/p&gt;
&lt;p&gt;
After a little wrangling, I pack up my dasBlog satchel and moved into the new digs.
Time to buy some new drapes and check out the neighborhood. I hope the local video
store has a good selection. I'll have to say goodbye to my (paultry) Google rankings,
for a little while at least.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.andrewdothay.net/blog/aggbug.ashx?id=ae037fa1-12a9-4b21-b9aa-9800aeff38d7" /&gt;</description>
      <comments>http://www.andrewdothay.net/blog/CommentView,guid,ae037fa1-12a9-4b21-b9aa-9800aeff38d7.aspx</comments>
      <category>asp.net</category>
    </item>
    <item>
      <trackback:ping>http://www.andrewdothay.net/blog/Trackback.aspx?guid=70c4aa09-dc40-4ded-8a45-8f6d96f1a02f</trackback:ping>
      <pingback:server>http://www.andrewdothay.net/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.andrewdothay.net/blog/PermaLink,guid,70c4aa09-dc40-4ded-8a45-8f6d96f1a02f.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.andrewdothay.net/blog/CommentView,guid,70c4aa09-dc40-4ded-8a45-8f6d96f1a02f.aspx</wfw:comment>
      <wfw:commentRss>http://www.andrewdothay.net/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=70c4aa09-dc40-4ded-8a45-8f6d96f1a02f</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
A friend from an adjacent firm, <a href="http://www.selytics.com">Selytics</a>, sent
me this <a href="http://support.microsoft.com/default.aspx?scid=915782">support.microsoft.com</a> link
to me the other day with the hopes that it would solve a problem. His turned
out to be a different issue, but after further reading, I wish I read this one a few
weeks ago.
</p>
        <p>
I was working on an ASP.Net 2.0 solution that included some web user controls. I was
periodically getting the error message 
</p>
        <div class="sourcecodeblock">Unable to cast object of type 'ASP.XXXtype' to type 'ASP.XXXtype'.
</div>
        <p>
Where XXXtype was the namespace and class of my web user control. The message
made little sense. There's no conversion. They are the same type on the left and right
sides.
</p>
        <p>
The problem was that a web user control was being dynamically compiled into the same
assembly as the hosting web page and loaded on the fly. It *ought* to work fine, but
was actually failing on occassion.
</p>
        <p>
The link above identifies the issue and the simple bandaid to web.config that
will cease batch compilation, but that's not good for a production environment. Evidently,
there's a patch you can get from Microsoft that will fix this specific issue and it
will be included in an upcoming service pack.
</p>
        <p>
Without that, I was forced to solve the problem by converting my web user controls
into custom server controls; an extra couple of hours that I hadn't planned on consuming
that day. Harumph.
</p>
        <img width="0" height="0" src="http://www.andrewdothay.net/blog/aggbug.ashx?id=70c4aa09-dc40-4ded-8a45-8f6d96f1a02f" />
      </body>
      <title>You may receive an InvalidCastException error in an ASP.NET-connected Web application</title>
      <guid isPermaLink="false">http://www.andrewdothay.net/blog/PermaLink,guid,70c4aa09-dc40-4ded-8a45-8f6d96f1a02f.aspx</guid>
      <link>http://www.andrewdothay.net/blog/2006/08/08/YouMayReceiveAnInvalidCastExceptionErrorInAnASPNETconnectedWebApplication.aspx</link>
      <pubDate>Tue, 08 Aug 2006 20:42:00 GMT</pubDate>
      <description>&lt;p&gt;
A&amp;nbsp;friend from an adjacent firm, &lt;a href="http://www.selytics.com"&gt;Selytics&lt;/a&gt;,&amp;nbsp;sent
me&amp;nbsp;this &lt;a href="http://support.microsoft.com/default.aspx?scid=915782"&gt;support.microsoft.com&lt;/a&gt; link
to me the other day with the hopes that it would solve a problem.&amp;nbsp;His turned
out to be a different issue, but after further reading, I wish I read this one a few
weeks ago.
&lt;/p&gt;
&lt;p&gt;
I was working on an ASP.Net 2.0 solution that included some web user controls. I was
periodically getting the error message 
&lt;/p&gt;
&lt;div class=sourcecodeblock&gt;Unable to cast object of type 'ASP.XXXtype' to type 'ASP.XXXtype'.
&lt;/div&gt;
&lt;p&gt;
Where XXXtype was the&amp;nbsp;namespace and class&amp;nbsp;of my web user control. The message
made little sense. There's no conversion. They are the same type on the left and right
sides.
&lt;/p&gt;
&lt;p&gt;
The problem was that a web user control was being dynamically compiled into the same
assembly as the hosting web page and loaded on the fly. It *ought* to work fine, but
was actually failing on occassion.
&lt;/p&gt;
&lt;p&gt;
The link above identifies the issue and the simple&amp;nbsp;bandaid to web.config that
will cease batch compilation, but that's not good for a production environment. Evidently,
there's a patch you can get from Microsoft that will fix this specific issue and it
will be included in an upcoming service pack.
&lt;/p&gt;
&lt;p&gt;
Without that, I was forced to solve the problem by converting my web user controls
into custom server controls; an extra couple of hours that I hadn't planned on consuming
that day. Harumph.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.andrewdothay.net/blog/aggbug.ashx?id=70c4aa09-dc40-4ded-8a45-8f6d96f1a02f" /&gt;</description>
      <comments>http://www.andrewdothay.net/blog/CommentView,guid,70c4aa09-dc40-4ded-8a45-8f6d96f1a02f.aspx</comments>
      <category>asp.net</category>
      <category>software</category>
    </item>
    <item>
      <trackback:ping>http://www.andrewdothay.net/blog/Trackback.aspx?guid=db42231b-5118-4751-a560-9dbb67eb430c</trackback:ping>
      <pingback:server>http://www.andrewdothay.net/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.andrewdothay.net/blog/PermaLink,guid,db42231b-5118-4751-a560-9dbb67eb430c.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.andrewdothay.net/blog/CommentView,guid,db42231b-5118-4751-a560-9dbb67eb430c.aspx</wfw:comment>
      <wfw:commentRss>http://www.andrewdothay.net/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=db42231b-5118-4751-a560-9dbb67eb430c</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
After a swell night at the Party in the Pinot, hosted by the <a href="http://www.aeanet.org/">local
AEA chapter</a> here in Portland, Oregon, I sauntered down to the basement, fired
up my laptop, and proceeded to install DNN 4.3.3 that was posted on 7/19/2006 on <a href="http://www.dotnetnuke.com/">www.dotnetnuke.com</a>. 
</p>
        <p>
I spotted some nifty looking items that I either (a) have yet to explore or (2) are
recent additions to the DNN core. Time to fill up the coffee with another 20oz helping
and dive in. Don't you just love Sundays?!!?
</p>
        <img alt="DNN 4.3.3" src="http://andrew.staging.popart.com/content/binary/dnn433installlog.png" border="1" />
        <img width="0" height="0" src="http://www.andrewdothay.net/blog/aggbug.ashx?id=db42231b-5118-4751-a560-9dbb67eb430c" />
      </body>
      <title>Checking out DNN 4.3.3</title>
      <guid isPermaLink="false">http://www.andrewdothay.net/blog/PermaLink,guid,db42231b-5118-4751-a560-9dbb67eb430c.aspx</guid>
      <link>http://www.andrewdothay.net/blog/2006/07/30/CheckingOutDNN433.aspx</link>
      <pubDate>Sun, 30 Jul 2006 19:11:41 GMT</pubDate>
      <description>&lt;p&gt;
After a swell night at the Party in the Pinot, hosted by the &lt;a href="http://www.aeanet.org/"&gt;local
AEA chapter&lt;/a&gt;&amp;nbsp;here in Portland, Oregon, I sauntered down to the basement, fired
up my laptop, and proceeded to install DNN 4.3.3 that was posted on 7/19/2006 on &lt;a href="http://www.dotnetnuke.com/"&gt;www.dotnetnuke.com&lt;/a&gt;. 
&lt;/p&gt;
&lt;p&gt;
I spotted some nifty looking items that I either (a) have yet to explore or (2) are
recent additions to the DNN core. Time to fill up the coffee with another 20oz helping
and dive in. Don't you just love Sundays?!!?
&lt;/p&gt;
&lt;img alt="DNN 4.3.3" src="http://andrew.staging.popart.com/content/binary/dnn433installlog.png" border=1&gt;&lt;img width="0" height="0" src="http://www.andrewdothay.net/blog/aggbug.ashx?id=db42231b-5118-4751-a560-9dbb67eb430c" /&gt;</description>
      <comments>http://www.andrewdothay.net/blog/CommentView,guid,db42231b-5118-4751-a560-9dbb67eb430c.aspx</comments>
      <category>asp.net</category>
      <category>DotNetNuke</category>
    </item>
    <item>
      <trackback:ping>http://www.andrewdothay.net/blog/Trackback.aspx?guid=a5941110-5cf8-41ac-8a9e-aafe2d7a18d5</trackback:ping>
      <pingback:server>http://www.andrewdothay.net/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.andrewdothay.net/blog/PermaLink,guid,a5941110-5cf8-41ac-8a9e-aafe2d7a18d5.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.andrewdothay.net/blog/CommentView,guid,a5941110-5cf8-41ac-8a9e-aafe2d7a18d5.aspx</wfw:comment>
      <wfw:commentRss>http://www.andrewdothay.net/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=a5941110-5cf8-41ac-8a9e-aafe2d7a18d5</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
With an extra helping of curiosity and hell bent on learning something new &amp; valuable,
I opened the book <a href="http://www.bbd.com/stylin/index.htm">Stylin’ with CSS,
A Designers Guide</a> written by Charles Wyke-Smith.
</p>
        <p>
I’ve been using CSS since the late 90’s so I’ve got most of the normal stuff committed
to memory. As a small aside, when I built my first site for Pop Art, I got a bunch
of Oohs and Ahhs for my use of CSS and then abruptly fell on my face when I realized
we had to support Netscape 4. So with some distance between us, I'm ready to get the
band back together.
</p>
        <p>
Before reading this book, I didn’t have a good grasp on CSS positioning. I consider
myself a fairly savvy pirate, so I said my best “Arrrrrgggg” and read the book. It’s
a really good read and chop full of examples. I highly recommend it. Here’s a few
things that I learned or thought of along the way:
</p>
        <h1>Percent of Content to Markup
</h1>
        <p>
Early in the book, Charles makes a point of comparing the HTML &lt;table&gt; method
with the CSS method of laying out a page. Using &lt;div&gt; tags results in much less
HTML around the content. When I read that, I thought back to my days of Assembly language
on an IBM OS/390 machine. This guy would have just hated to see what it took to open
a file, write something to it and close it. Hee!
</p>
        <h1>Quirks Mode
</h1>
        <p>
I first heard of quirks mode about a year ago while listening to a podcast. You’re
in quirks mode if you don’t declare the document type in Internet Explorer; in which
case IE will try to guess how to render the site. It normally does a really good job,
but it can behave oddly and render some markup in an unexpected manner. Its best to
steer clear of quirks mode. You no likey.
</p>
        <h1>Content Type Meta Tag
</h1>
        <p>
I learned this tag the hard way on a client site. Some of the text was rendering the
odd, non-printable characters, but only for certain browsers. It turned out that if
you set the encoding in IE manually it would work, but auto-select behaved oddly.
Simply setting the content type via a meta tag in the web page told IE what to expect
and the problem was solved. 
</p>
        <h1>Child Selectors and XPath
</h1>
        <p>
CSS has a way of defining selectors that resembles that XPath syntax. XPath is a way
to query an XML document for things like “get the third child of a node that is named
“employee”.
</p>
        <p>
This is how you would write a rule that says make content inside an &lt;em&gt; tag
green if its directly a child of the &lt;p&gt; tag:
</p>
        <div class="sourcecodeblock">p&gt;em {color:green;} 
</div>
        <p>
There’s also a way to select adjacent tags, a similar concept in XPath. Here’s the
rule to select a &lt;p&gt; tag that is adjacent to an &lt;h1&gt; tag:
</p>
        <div class="sourcecodeblock">h1 + p {font-variant:small-caps;}
</div>
        <p>
There’s even a way to select tags based on their attributes. This is something that’s
done all the time when you write an XSLT document. This rule sets a border around
&lt;img&gt; tags when they have a title attribute:
</p>
        <div class="sourcecodeblock">img[title] {border:2px solid blue;}
</div>
        <h1>Universal Selector
</h1>
        <p>
The universal selector was new to me. The asterisk means anything, so this is the
rule to make all margins and padding set to zero. This sets all browsers to the same
standard, rather than relay on all browsers to have a similar padding and margin for
their &lt;p&gt; tags (which is a bad thing to rely on).
</p>
        <div class="sourcecodeblock">* {margin:0px; padding:0px}
</div>
        <h1>Pseudo-Classes and Pseudo-Elements
</h1>
        <p>
You’re probably familiar with the pseudo-classes for the anchor tag, &lt;a&gt;:
</p>
        <div class="sourcecodeblock">a:link { color:#000; }<br />
a:visited { color:#FF0000; }<br />
a:hover { color:#FFF; }<br />
a:active { color:#CCC; }
</div>
        <p>
Pseudo-classes are helpful when you need to change a class based on the state of the
item. Pseudo-elements were brand new to me. 
</p>
        <p>
I can target the first letter in an element:
</p>
        <div class="sourcecodeblock">p:first-letter { font-size:20pt; }
</div>
        <p>
and I can also target the entire first line:
</p>
        <div class="sourcecodeblock">p:first-line { font-variant:small-caps; }
</div>
        <p>
There are a bunch of other pseudo-elements like x:before and x:after, which get to
a very elegant way of clearing a float. This next method injects code into the page
using the :after pseudo-element.
</p>
        <h1>Alsett Clearing Method
</h1>
        <p>
When you float some elements left or write. One way to stop a lower element from floating
beside it is to set the “clear” instruction. Depending on your content is marked up,
this might be easy. However, it might require the use of some markup that has no other
purpose than to clear your float. This is something that should make your little CSS
red flag go up. So, some smart person named <a href="http://www.csscreator.com/">Tony
Alsett</a> figured out a snazzy way to insert some non-floated content in the page
just using CSS. So all you need is the right CSS class or ID reference and you’re
done. No crap hanging out in the markup just for presentational purposes.
</p>
        <p>
Here’s the technique:
</p>
        <div class="sourcecodeblock">.clearfix:after<br />
{ <br />
   content: “.”; <br />
   display:block; <br />
   height: 0; <br />
   clear:both; <br />
   visibility:hidden;<br />
}<br />
.clearfix { display:inline-block;}<br />
html .clearfix { height:1%;}<br />
.clearfix {display:block;}
</div>
        <p>
So, not that you would ever come up with this hack on your own, but this is the stuff
that gets you to a CSS standards based website with minimal presentation markup in
your XHTML file.
</p>
        <p>
So now we get on to the good stuff.
</p>
        <h1>Positioning
</h1>
        <h3>Set all margins and padding to zero
</h3>
        <p>
Just like a good brew master cleans his equipment before making a batch of BS IPA,
you should set all margins and padding to zero as a first step.
</p>
        <div class="sourcecodeblock">* {margin:0; padding:0}
</div>
        <h3>Vertical Margins Collapse
</h3>
        <p>
When you set vertical margins on tags, remember that when they meet, they will overlap
margins until one of the margins touches the border of the other element; they collapse.
This is not the case for horizontal margins. They no collapsey.
</p>
        <h3>How Big Is a Box
</h3>
        <p>
This is topic that can make you screwy if you care too deeply about multiple browsers.
When you set a with on a &lt;p&gt; tag to 400px and then add a left and right pad
of 50px, you’ve just created a 500px wide &lt;p&gt; tag. Now, if you add a border,
the width will grow even more. Basically, its additive. It doesn’t shrink the contents
of the &lt;p&gt; tag to keep the element set to 400px. 
</p>
        <p>
So now that you think you’ve got that, keep in mind that IE 5 and IE 5.5 for Windows
handles the box model differently. They do squeeze the content if you pad it. IE 6
does the same thing in Quirks mode too. Like I said, don’t be in Quirks mode, jerk.
</p>
        <h1>The Positioning Property
</h1>
        <p>
So, here it is. Positioning. Mmmm. Doesn’t it smell good?
</p>
        <h3>Static Positioning
</h3>
        <p>
This is the default. You know how it works, so move on. Nothing to see here.
</p>
        <h3>Relative Positioning
</h3>
When you set a tag to render using relative positioning, it renders relative to where
it would have gone normally. For example, this rule will push a &lt;p&gt; tag down
30px and left 20px from where it would have normally rendered: 
<p></p><div class="sourcecodeblock">.MyRelativeParaGraph { position:relative; top:30px; left:30px;
}
</div><p>
Now, your &lt;p&gt; will be moved, and perhaps on top of thing item below it in the
flow of the document.
</p><h3>Absolute Positioning
</h3><p>
This setting takes the item out of the flow of the document. It’s baseline is the
item that is the positioning context for the absolutely positioned element. By default,
the body tag is the positioning context for elements. You can set a different positioning
context by using two tags, one nested inside the other. The outer tag can be set to
relative positioning. This makes the outer tag the positioning context for the inner
tag. The inner tag is set to absolute positioning and thus the &lt;body&gt; tag is
no longer the baseline.
</p><h3>Fixed Positioning
</h3><p>
This blows, don’t do it. It keeps an item fixed on a given spot in your browser, regardless
of where you scroll in a long document. It’s fixed. Get it?
</p><h1>Floating &amp; Clearing
</h1><p>
Floating and clearing allow for the creating of a two or three column template in
the book. It’s a pretty cool concept. The easiest way to think about it is a simple
two column layout. Imagine a simple page with two &lt;div&gt; tags. You can make a
simple two column layout with these CSS rules:
</p><div class="sourcecodeblock">#div1 { float:left; width:200px; background-color:#FFFF00;
}<br />
#div2 { background-color:#FF0000; }
</div><p>
Three column layouts are nearly as easy. Its sweet tasty goodness. Dish up!
</p><img width="0" height="0" src="http://www.andrewdothay.net/blog/aggbug.ashx?id=a5941110-5cf8-41ac-8a9e-aafe2d7a18d5" /></body>
      <title>Stylin' with CSS, A Designers Guide</title>
      <guid isPermaLink="false">http://www.andrewdothay.net/blog/PermaLink,guid,a5941110-5cf8-41ac-8a9e-aafe2d7a18d5.aspx</guid>
      <link>http://www.andrewdothay.net/blog/2006/07/25/StylinWithCSSADesignersGuide.aspx</link>
      <pubDate>Tue, 25 Jul 2006 01:10:56 GMT</pubDate>
      <description>&lt;p&gt;
With an extra helping of curiosity and hell bent on learning something new &amp;amp; valuable,
I opened the book &lt;a href="http://www.bbd.com/stylin/index.htm"&gt;Stylin’ with CSS,
A Designers Guide&lt;/a&gt; written by Charles Wyke-Smith.
&lt;/p&gt;
&lt;p&gt;
I’ve been using CSS since the late 90’s so I’ve got most of the normal stuff committed
to memory. As a small aside, when I built my first site for Pop Art, I got a bunch
of Oohs and Ahhs for my use of CSS and then abruptly fell on my face when I realized
we had to support Netscape 4. So with some distance between us, I'm ready to get the
band back together.
&lt;/p&gt;
&lt;p&gt;
Before reading this book, I didn’t have a good grasp on CSS positioning. I consider
myself a fairly savvy pirate, so I said my best “Arrrrrgggg” and read the book. It’s
a really good read and chop full of examples. I highly recommend it. Here’s a few
things that I learned or thought of along the way:
&lt;/p&gt;
&lt;h1&gt;Percent of Content to Markup
&lt;/h1&gt;
&lt;p&gt;
Early in the book, Charles makes a point of comparing the HTML &amp;lt;table&amp;gt; method
with the CSS method of laying out a page. Using &amp;lt;div&amp;gt; tags results in much less
HTML around the content. When I read that, I thought back to my days of Assembly language
on an IBM OS/390 machine. This guy would have just hated to see what it took to open
a file, write something to it and close it. Hee!
&lt;/p&gt;
&lt;h1&gt;Quirks Mode
&lt;/h1&gt;
&lt;p&gt;
I first heard of quirks mode about a year ago while listening to a podcast. You’re
in quirks mode if you don’t declare the document type in Internet Explorer; in which
case IE will try to guess how to render the site. It normally does a really good job,
but it can behave oddly and render some markup in an unexpected manner. Its best to
steer clear of quirks mode. You no likey.
&lt;/p&gt;
&lt;h1&gt;Content Type Meta Tag
&lt;/h1&gt;
&lt;p&gt;
I learned this tag the hard way on a client site. Some of the text was rendering the
odd, non-printable characters, but only for certain browsers. It turned out that if
you set the encoding in IE manually it would work, but auto-select behaved oddly.
Simply setting the content type via a meta tag in the web page told IE what to expect
and the problem was solved. 
&lt;/p&gt;
&lt;h1&gt;Child Selectors and XPath
&lt;/h1&gt;
&lt;p&gt;
CSS has a way of defining selectors that resembles that XPath syntax. XPath is a way
to query an XML document for things like “get the third child of a node that is named
“employee”.
&lt;/p&gt;
&lt;p&gt;
This is how you would write a rule that says make content inside an &amp;lt;em&amp;gt; tag
green if its directly a child of the &amp;lt;p&amp;gt; tag:
&lt;/p&gt;
&lt;div class=sourcecodeblock&gt;p&amp;gt;em {color:green;} 
&lt;/div&gt;
&lt;p&gt;
There’s also a way to select adjacent tags, a similar concept in XPath. Here’s the
rule to select a &amp;lt;p&amp;gt; tag that is adjacent to an &amp;lt;h1&amp;gt; tag:
&lt;/p&gt;
&lt;div class=sourcecodeblock&gt;h1 + p {font-variant:small-caps;}
&lt;/div&gt;
&lt;p&gt;
There’s even a way to select tags based on their attributes. This is something that’s
done all the time when you write an XSLT document. This rule sets a border around
&amp;lt;img&amp;gt; tags when they have a title attribute:
&lt;/p&gt;
&lt;div class=sourcecodeblock&gt;img[title] {border:2px solid blue;}
&lt;/div&gt;
&lt;h1&gt;Universal Selector
&lt;/h1&gt;
&lt;p&gt;
The universal selector was new to me. The asterisk means anything, so this is the
rule to make all margins and padding set to zero. This sets all browsers to the same
standard, rather than relay on all browsers to have a similar padding and margin for
their &amp;lt;p&amp;gt; tags (which is a bad thing to rely on).
&lt;/p&gt;
&lt;div class=sourcecodeblock&gt;* {margin:0px; padding:0px}
&lt;/div&gt;
&lt;h1&gt;Pseudo-Classes and Pseudo-Elements
&lt;/h1&gt;
&lt;p&gt;
You’re probably familiar with the pseudo-classes for the anchor tag, &amp;lt;a&amp;gt;:
&lt;/p&gt;
&lt;div class=sourcecodeblock&gt;a:link { color:#000; }&lt;br&gt;
a:visited { color:#FF0000; }&lt;br&gt;
a:hover { color:#FFF; }&lt;br&gt;
a:active { color:#CCC; }
&lt;/div&gt;
&lt;p&gt;
Pseudo-classes are helpful when you need to change a class based on the state of the
item. Pseudo-elements were brand new to me. 
&lt;/p&gt;
&lt;p&gt;
I can target the first letter in an element:
&lt;/p&gt;
&lt;div class=sourcecodeblock&gt;p:first-letter { font-size:20pt; }
&lt;/div&gt;
&lt;p&gt;
and I can also target the entire first line:
&lt;/p&gt;
&lt;div class=sourcecodeblock&gt;p:first-line { font-variant:small-caps; }
&lt;/div&gt;
&lt;p&gt;
There are a bunch of other pseudo-elements like x:before and x:after, which get to
a very elegant way of clearing a float. This next method injects code into the page
using the :after pseudo-element.
&lt;/p&gt;
&lt;h1&gt;Alsett Clearing Method
&lt;/h1&gt;
&lt;p&gt;
When you float some elements left or write. One way to stop a lower element from floating
beside it is to set the “clear” instruction. Depending on your content is marked up,
this might be easy. However, it might require the use of some markup that has no other
purpose than to clear your float. This is something that should make your little CSS
red flag go up. So, some smart person named &lt;a href="http://www.csscreator.com/"&gt;Tony
Alsett&lt;/a&gt; figured out a snazzy way to insert some non-floated content in the page
just using CSS. So all you need is the right CSS class or ID reference and you’re
done. No crap hanging out in the markup just for presentational purposes.
&lt;/p&gt;
&lt;p&gt;
Here’s the technique:
&lt;/p&gt;
&lt;div class=sourcecodeblock&gt;.clearfix:after&lt;br&gt;
{&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;content: “.”;&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;display:block;&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;height: 0;&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;clear:both;&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;visibility:hidden;&lt;br&gt;
}&lt;br&gt;
.clearfix { display:inline-block;}&lt;br&gt;
html .clearfix { height:1%;}&lt;br&gt;
.clearfix {display:block;}
&lt;/div&gt;
&lt;p&gt;
So, not that you would ever come up with this hack on your own, but this is the stuff
that gets you to a CSS standards based website with minimal presentation markup in
your XHTML file.
&lt;/p&gt;
&lt;p&gt;
So now we get on to the good stuff.
&lt;/p&gt;
&lt;h1&gt;Positioning
&lt;/h1&gt;
&lt;h3&gt;Set all margins and padding to zero
&lt;/h3&gt;
&lt;p&gt;
Just like a good brew master cleans his equipment before making a batch of BS IPA,
you should set all margins and padding to zero as a first step.
&lt;/p&gt;
&lt;div class=sourcecodeblock&gt;* {margin:0; padding:0}
&lt;/div&gt;
&lt;h3&gt;Vertical Margins Collapse
&lt;/h3&gt;
&lt;p&gt;
When you set vertical margins on tags, remember that when they meet, they will overlap
margins until one of the margins touches the border of the other element; they collapse.
This is not the case for horizontal margins. They no collapsey.
&lt;/p&gt;
&lt;h3&gt;How Big Is a Box
&lt;/h3&gt;
&lt;p&gt;
This is topic that can make you screwy if you care too deeply about multiple browsers.
When you set a with on a &amp;lt;p&amp;gt; tag to 400px and then add a left and right pad
of 50px, you’ve just created a 500px wide &amp;lt;p&amp;gt; tag. Now, if you add a border,
the width will grow even more. Basically, its additive. It doesn’t shrink the contents
of the &amp;lt;p&amp;gt; tag to keep the element set to 400px. 
&lt;/p&gt;
&lt;p&gt;
So now that you think you’ve got that, keep in mind that IE 5 and IE 5.5 for Windows
handles the box model differently. They do squeeze the content if you pad it. IE 6
does the same thing in Quirks mode too. Like I said, don’t be in Quirks mode, jerk.
&lt;/p&gt;
&lt;h1&gt;The Positioning Property
&lt;/h1&gt;
&lt;p&gt;
So, here it is. Positioning. Mmmm. Doesn’t it smell good?
&lt;/p&gt;
&lt;h3&gt;Static Positioning
&lt;/h3&gt;
&lt;p&gt;
This is the default. You know how it works, so move on. Nothing to see here.
&lt;/p&gt;
&lt;h3&gt;Relative Positioning
&lt;/h3&gt;
When you set a tag to render using relative positioning, it renders relative to where
it would have gone normally. For example, this rule will push a &amp;lt;p&amp;gt; tag down
30px and left 20px from where it would have normally rendered: 
&lt;p&gt;
&lt;/p&gt;
&lt;div class=sourcecodeblock&gt;.MyRelativeParaGraph { position:relative; top:30px; left:30px;
}
&lt;/div&gt;
&lt;p&gt;
Now, your &amp;lt;p&amp;gt; will be moved, and perhaps on top of thing item below it in the
flow of the document.
&lt;/p&gt;
&lt;h3&gt;Absolute Positioning
&lt;/h3&gt;
&lt;p&gt;
This setting takes the item out of the flow of the document. It’s baseline is the
item that is the positioning context for the absolutely positioned element. By default,
the body tag is the positioning context for elements. You can set a different positioning
context by using two tags, one nested inside the other. The outer tag can be set to
relative positioning. This makes the outer tag the positioning context for the inner
tag. The inner tag is set to absolute positioning and thus the &amp;lt;body&amp;gt; tag is
no longer the baseline.
&lt;/p&gt;
&lt;h3&gt;Fixed Positioning
&lt;/h3&gt;
&lt;p&gt;
This blows, don’t do it. It keeps an item fixed on a given spot in your browser, regardless
of where you scroll in a long document. It’s fixed. Get it?
&lt;/p&gt;
&lt;h1&gt;Floating &amp;amp; Clearing
&lt;/h1&gt;
&lt;p&gt;
Floating and clearing allow for the creating of a two or three column template in
the book. It’s a pretty cool concept. The easiest way to think about it is a simple
two column layout. Imagine a simple page with two &amp;lt;div&amp;gt; tags. You can make a
simple two column layout with these CSS rules:
&lt;/p&gt;
&lt;div class=sourcecodeblock&gt;#div1 { float:left; width:200px; background-color:#FFFF00;
}&lt;br&gt;
#div2 { background-color:#FF0000; }
&lt;/div&gt;
&lt;p&gt;
Three column layouts are nearly as easy. Its sweet tasty goodness. Dish up!
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.andrewdothay.net/blog/aggbug.ashx?id=a5941110-5cf8-41ac-8a9e-aafe2d7a18d5" /&gt;</description>
      <comments>http://www.andrewdothay.net/blog/CommentView,guid,a5941110-5cf8-41ac-8a9e-aafe2d7a18d5.aspx</comments>
      <category>asp.net</category>
      <category>learning</category>
    </item>
    <item>
      <trackback:ping>http://www.andrewdothay.net/blog/Trackback.aspx?guid=46a9fab4-946b-42b6-933b-5eb8707a8292</trackback:ping>
      <pingback:server>http://www.andrewdothay.net/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.andrewdothay.net/blog/PermaLink,guid,46a9fab4-946b-42b6-933b-5eb8707a8292.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.andrewdothay.net/blog/CommentView,guid,46a9fab4-946b-42b6-933b-5eb8707a8292.aspx</wfw:comment>
      <wfw:commentRss>http://www.andrewdothay.net/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=46a9fab4-946b-42b6-933b-5eb8707a8292</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
And the last presentation of the day, <a href="http://atlas.asp.net/">ATLAS</a>! 
</p>
        <p>
The best part of this was getting to meet <a href="http://andrew.staging.popart.com/www.west-wind.com">Rick
Strahl</a>. I'm reasonably familiar with the material and it got the normal gasps
and as usual, it got bogged down by questions from the audience. The room was
packed and about five or ten people had to stand in the back. When the meeting started
getting bogged down with questions, I fired up a new print cycle of my <a href="http://safari.oreilly.com/0596526725">ATLAS
Rough Cuts</a> on Safari Books Online. It might be done printing by now, maybe I should
got back to the site and check.
</p>
        <p>
Rick only made it through about half of his content. He's a great presenter and has
some cool ideas. My friend, <a href="http://kelly.staging.popart.com/">Kelly</a>,
has been reading his blog and now I'm on board. The website has an interesting <a href="http://west-wind.com/westwindwebstore/">e-commerce
package</a> for sale. I'm going to check that out in a few weeks. He was using <a href="http://andrew.staging.popart.com/2006/07/12/FiddlerRocks.aspx">Fiddler</a> to
watch traffic for his AJAX code. I got a few ideas on things to look at in Fiddler
just by watching him use the tool. 
</p>
        <p>
This was a great code camp. Too bad the sprinklers came on and doused the audio equipment.
Its was pretty damn hot and my folf skills are definitely better in my head than in
the field. Maybe its just that crazy disc. I think I could throw better with a normal
disc until I earn my green belt and need a driver and a putter in my line up.
</p>
        <img width="0" height="0" src="http://www.andrewdothay.net/blog/aggbug.ashx?id=46a9fab4-946b-42b6-933b-5eb8707a8292" />
      </body>
      <title>Code Camp - Taking ATLAS for a Ride</title>
      <guid isPermaLink="false">http://www.andrewdothay.net/blog/PermaLink,guid,46a9fab4-946b-42b6-933b-5eb8707a8292.aspx</guid>
      <link>http://www.andrewdothay.net/blog/2006/07/24/CodeCampTakingATLASForARide.aspx</link>
      <pubDate>Mon, 24 Jul 2006 15:33:16 GMT</pubDate>
      <description>&lt;p&gt;
And the last presentation of the day, &lt;a href="http://atlas.asp.net/"&gt;ATLAS&lt;/a&gt;! 
&lt;/p&gt;
&lt;p&gt;
The best part of this was getting to meet &lt;a href="http://andrew.staging.popart.com/www.west-wind.com"&gt;Rick
Strahl&lt;/a&gt;. I'm reasonably familiar with the material and it got the normal gasps
and as usual, it got bogged down by questions from the audience.&amp;nbsp;The room was
packed and about five or ten people had to stand in the back. When the meeting started
getting bogged down with questions, I fired up a new print cycle of my &lt;a href="http://safari.oreilly.com/0596526725"&gt;ATLAS
Rough Cuts&lt;/a&gt; on Safari Books Online. It might be done printing by now, maybe I should
got back to the site and check.
&lt;/p&gt;
&lt;p&gt;
Rick only made it through about half of his content. He's&amp;nbsp;a great presenter and&amp;nbsp;has
some cool ideas. My friend, &lt;a href="http://kelly.staging.popart.com/"&gt;Kelly&lt;/a&gt;,
has been reading his blog and now I'm on board. The website has an interesting &lt;a href="http://west-wind.com/westwindwebstore/"&gt;e-commerce
package&lt;/a&gt; for sale. I'm going to check that out in a few weeks. He was using &lt;a href="http://andrew.staging.popart.com/2006/07/12/FiddlerRocks.aspx"&gt;Fiddler&lt;/a&gt; to
watch traffic&amp;nbsp;for his AJAX code. I got a few ideas on things to look at in Fiddler
just by watching him use the tool. 
&lt;/p&gt;
&lt;p&gt;
This was a great code camp. Too bad the sprinklers came on and doused the audio equipment.
Its was pretty damn hot and my folf skills are definitely better in my head than in
the field. Maybe its just that crazy disc. I think I could throw better with a normal
disc until I earn my green belt and need a driver and a putter in my line up.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.andrewdothay.net/blog/aggbug.ashx?id=46a9fab4-946b-42b6-933b-5eb8707a8292" /&gt;</description>
      <comments>http://www.andrewdothay.net/blog/CommentView,guid,46a9fab4-946b-42b6-933b-5eb8707a8292.aspx</comments>
      <category>asp.net</category>
      <category>software</category>
    </item>
    <item>
      <trackback:ping>http://www.andrewdothay.net/blog/Trackback.aspx?guid=18e274e9-345a-4940-8e1f-cdcb01fdc54e</trackback:ping>
      <pingback:server>http://www.andrewdothay.net/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.andrewdothay.net/blog/PermaLink,guid,18e274e9-345a-4940-8e1f-cdcb01fdc54e.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.andrewdothay.net/blog/CommentView,guid,18e274e9-345a-4940-8e1f-cdcb01fdc54e.aspx</wfw:comment>
      <wfw:commentRss>http://www.andrewdothay.net/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=18e274e9-345a-4940-8e1f-cdcb01fdc54e</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Scott Guthrie has some problem/solution postings on his blog. Here's a useful one
that I didn't know: <a href="http://weblogs.asp.net/scottgu/archive/2006/07/09/Tip_2F00_Trick_3A00_-Using-Server-Side-Comments-with-ASP.NET-2.0-.aspx">Server
Side Comments</a>.
</p>
        <p>
When I comment out user controls and server controls on an .aspx page, I
always used the client side comment style, which is the common HTML comment tags of
&lt;!-- and --&gt;.
</p>
        <p>
However, I knew that the controls would still execute on the server, and could cause
a compile error. So I always had to rename the runat="server" attribute to something
like runatXXX="server" to hide it from ASP.Net
</p>
        <p>
Now, I can just use this syntax to temporarily comment out a few lines and leave the
runat attribute alone. Yay!
</p>
        <div style="BORDER-RIGHT: #000000 1px solid; PADDING-RIGHT: 10px; BORDER-TOP: #000000 1px solid; PADDING-LEFT: 10px; PADDING-BOTTOM: 10px; BORDER-LEFT: #000000 1px solid; PADDING-TOP: 10px; BORDER-BOTTOM: #000000 1px solid; FONT-FAMILY: courier new; BACKGROUND-COLOR: khaki">
          <p>
            <span style="BACKGROUND-COLOR: yellow">&lt;%--</span>
          </p>
          <p>
   Commented out HTML/CODE/Markup.  Anything with 
<br />
   this block will not be parsed/handled by ASP.NET. 
</p>
          <p>
   &lt;asp:Calendar runat="server"&gt;&lt;/asp:Calendar&gt;  
</p>
          <p>
   &lt;%# Eval(“SomeProperty”) %&gt;      
</p>
          <p>
            <span style="BACKGROUND-COLOR: yellow">--%&gt;</span>
            <br />
          </p>
        </div>
        <p>
Ok, so if you already knew this, why didn't you tell me?
</p>
        <img width="0" height="0" src="http://www.andrewdothay.net/blog/aggbug.ashx?id=18e274e9-345a-4940-8e1f-cdcb01fdc54e" />
      </body>
      <title>Server Side Comments</title>
      <guid isPermaLink="false">http://www.andrewdothay.net/blog/PermaLink,guid,18e274e9-345a-4940-8e1f-cdcb01fdc54e.aspx</guid>
      <link>http://www.andrewdothay.net/blog/2006/07/14/ServerSideComments.aspx</link>
      <pubDate>Fri, 14 Jul 2006 17:26:50 GMT</pubDate>
      <description>&lt;p&gt;
Scott Guthrie has some problem/solution postings on his blog. Here's a useful one
that I didn't know: &lt;a href="http://weblogs.asp.net/scottgu/archive/2006/07/09/Tip_2F00_Trick_3A00_-Using-Server-Side-Comments-with-ASP.NET-2.0-.aspx"&gt;Server
Side Comments&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
When I comment out&amp;nbsp;user controls and server controls&amp;nbsp;on an .aspx page, I
always used the client side comment style, which is the common HTML comment tags of
&amp;lt;!-- and --&amp;gt;.
&lt;/p&gt;
&lt;p&gt;
However, I knew that the controls would still execute on the server, and could cause
a compile error. So I always had to rename the runat="server" attribute to something
like runatXXX="server" to hide it from ASP.Net
&lt;/p&gt;
&lt;p&gt;
Now, I can just use this syntax to temporarily comment out a few lines and leave the
runat attribute alone. Yay!
&lt;/p&gt;
&lt;div style="BORDER-RIGHT: #000000 1px solid; PADDING-RIGHT: 10px; BORDER-TOP: #000000 1px solid; PADDING-LEFT: 10px; PADDING-BOTTOM: 10px; BORDER-LEFT: #000000 1px solid; PADDING-TOP: 10px; BORDER-BOTTOM: #000000 1px solid; FONT-FAMILY: courier new; BACKGROUND-COLOR: khaki"&gt;
&lt;p&gt;
&lt;span style="BACKGROUND-COLOR: yellow"&gt;&amp;lt;%--&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;&amp;nbsp; Commented out HTML/CODE/Markup.&amp;nbsp; Anything with 
&lt;br&gt;
&amp;nbsp;&amp;nbsp; this block will not be parsed/handled by ASP.NET. 
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;asp:Calendar runat="server"&amp;gt;&amp;lt;/asp:Calendar&amp;gt;&amp;nbsp; 
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;%# Eval(“SomeProperty”) %&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;/p&gt;
&lt;p&gt;
&lt;span style="BACKGROUND-COLOR: yellow"&gt;--%&amp;gt;&lt;/span&gt;
&lt;br&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;
Ok, so if you already knew this, why didn't you tell me?
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.andrewdothay.net/blog/aggbug.ashx?id=18e274e9-345a-4940-8e1f-cdcb01fdc54e" /&gt;</description>
      <comments>http://www.andrewdothay.net/blog/CommentView,guid,18e274e9-345a-4940-8e1f-cdcb01fdc54e.aspx</comments>
      <category>asp.net</category>
    </item>
  </channel>
</rss>