<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Everything Web</title>
	<atom:link href="http://multitiered.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://multitiered.wordpress.com</link>
	<description>From .NET to Sitecore, SQL, JQuery and everything in between...</description>
	<lastBuildDate>Wed, 28 Sep 2011 12:41:35 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='multitiered.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Everything Web</title>
		<link>http://multitiered.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://multitiered.wordpress.com/osd.xml" title="Everything Web" />
	<atom:link rel='hub' href='http://multitiered.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Sitecore Analytics Data Loss: Max Size of Insert Queue Reached</title>
		<link>http://multitiered.wordpress.com/2011/01/14/sitecore-analytics-data-loss-max-size-of-insert-queue-reached/</link>
		<comments>http://multitiered.wordpress.com/2011/01/14/sitecore-analytics-data-loss-max-size-of-insert-queue-reached/#comments</comments>
		<pubDate>Sat, 15 Jan 2011 04:36:48 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Sitecore]]></category>
		<category><![CDATA[Analytics]]></category>

		<guid isPermaLink="false">http://multitiered.wordpress.com/?p=487</guid>
		<description><![CDATA[For high traffic websites using Sitecore Analytics, you may run into instances where you find the following warning in your Sitecore logs: Analystics: Max size of insert queue reached. Dropped 2680. While this may seem like just a warning, the truth is, you&#8217;re losing data. The warning message tells you exactly how many database writes [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=multitiered.wordpress.com&amp;blog=14707195&amp;post=487&amp;subd=multitiered&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>For high traffic websites using Sitecore Analytics, you may run into instances where you find the following warning in your Sitecore logs:</p>
<pre>
Analystics: Max size of insert queue reached. Dropped 2680.
</pre>
<p>While this may seem like just a warning, the truth is, you&#8217;re losing data. </p>
<p>The warning message tells you exactly how many database writes were attempted to be queued, but dropped in the current session. </p>
<h3>Further Analysis</h3>
<p>Sitecore Analytics runs as a multi-threaded background process collecting thread requests to write data to the Analytics database. When the number of requests queued is greater than the threshold set in your Analytics.Config file, warnings are written for every 25 failures discovered and those additional requests are discarded with no way to recover the data.</p>
<p>Your only solution is to increase your <strong>MaxQueueSize</strong> attribute in the <strong>Analytics.Config</strong> file. Just make sure your servers can handle the load. </p>
<p>Using reflector, the method used to queue requests to be written to the database shows the vulnerability. Keep in mind this method is used in</p>
<ul>
<li>Creating campaign events</li>
<li>Updating visitor identity</li>
<li>All HTTP and Media request handling</li>
</ul>
<p>The public static method <strong>Enqueue</strong>, exposed in the <strong>DatabaseSubmitter</strong> class of <strong>Sitecore.Analytics.Data</strong> places tracking in queue to be updated in the Analytics database. </p>
<pre style="font-family:consolas;">
<span style="color:blue;">private</span>&nbsp;<span style="color:blue;">static</span>&nbsp;<span style="color:blue;">readonly</span>&nbsp;<span style="color:blue;">int</span>&nbsp;maxSize&nbsp;=&nbsp;Settings.GetIntSetting(<span style="color:#a31515;">&quot;Analytics.MaxQueueSize&quot;</span>,&nbsp;500);

...

<span style="color:blue;">public</span>&nbsp;<span style="color:blue;">static</span>&nbsp;<span style="color:blue;">void</span>&nbsp;Enqueue(<span style="color:#2b91af;">IDatabaseSubmittable</span>&nbsp;databaseSubmittable){
&nbsp;&nbsp;&nbsp;&nbsp;Assert.ArgumentNotNull(databaseSubmittable,&nbsp;<span style="color:#a31515;">&quot;databaseSubmittable&quot;</span>);&nbsp;&nbsp;&nbsp;&nbsp;
<span style="color:blue;">&nbsp;&nbsp;&nbsp;&nbsp;lock</span>&nbsp;(syncQueue)&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:blue;">if</span>&nbsp;(queue.Count&nbsp;&gt;&nbsp;maxSize)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#2b91af;">AnalyticsManager</span>.SetStatusFailed(<span style="color:#2b91af;">AnalyticsManager</span>.STATUS_QUEUE_FULL);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;failed++;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:blue;">if</span>&nbsp;((failed&nbsp;%&nbsp;0x19)&nbsp;==&nbsp;1)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Log.Warn(
<span style="color:blue;">string</span>.Format(<span style="color:#a31515;">&quot;Analystics:&nbsp;Max&nbsp;size&nbsp;of&nbsp;insert&nbsp;queue&nbsp;reached.&nbsp;Dropped&nbsp;{0}.&quot;</span>,&nbsp;failed),&nbsp;<span style="color:blue;">typeof</span>(<span style="color:#2b91af;">DatabaseSubmitter</span>));&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:blue;">else</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;queue.Add(databaseSubmittable);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;}
}
</pre>
<p>Lets hope future versions of Sitecore Analytics will provide better ways of dealing with excessive load than dropping data without having a way to recover it. </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/multitiered.wordpress.com/487/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/multitiered.wordpress.com/487/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/multitiered.wordpress.com/487/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/multitiered.wordpress.com/487/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/multitiered.wordpress.com/487/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/multitiered.wordpress.com/487/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/multitiered.wordpress.com/487/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/multitiered.wordpress.com/487/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/multitiered.wordpress.com/487/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/multitiered.wordpress.com/487/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/multitiered.wordpress.com/487/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/multitiered.wordpress.com/487/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/multitiered.wordpress.com/487/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/multitiered.wordpress.com/487/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=multitiered.wordpress.com&amp;blog=14707195&amp;post=487&amp;subd=multitiered&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://multitiered.wordpress.com/2011/01/14/sitecore-analytics-data-loss-max-size-of-insert-queue-reached/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/eb46b0549be16729844d43f494e0f45d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">udpeters</media:title>
		</media:content>
	</item>
		<item>
		<title>Tracking Selenium Commands Using C# and SQL Server 2008</title>
		<link>http://multitiered.wordpress.com/2010/09/13/tracking-selenium-commands-using-c-and-sql-server-2008/</link>
		<comments>http://multitiered.wordpress.com/2010/09/13/tracking-selenium-commands-using-c-and-sql-server-2008/#comments</comments>
		<pubDate>Tue, 14 Sep 2010 03:10:59 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Continuous Integration]]></category>
		<category><![CDATA[Selenium]]></category>

		<guid isPermaLink="false">http://multitiered.wordpress.com/?p=357</guid>
		<description><![CDATA[When running a suite of Selenium tests, I wanted an easy way of looking at the pages visited as well as commands executed during each unit test. To solve this problem, I designed a solution built on top of the core Selenium classes that records all unit test data to a SQL Server 2008 database. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=multitiered.wordpress.com&amp;blog=14707195&amp;post=357&amp;subd=multitiered&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>When running a suite of Selenium tests, I wanted an easy way of looking at the pages visited as well as commands executed during each unit test. To solve this problem, I designed a solution built on top of the core Selenium classes that records all unit test data to a SQL Server 2008 database. </p>
<p>In this post, details of the following are covered:</p>
<ul>
<li><strong>Back End Design</strong> &#8211; Database schema overview.</li>
<li><strong>Core logic</strong> &#8211; The class that drives tracking of the test.</li>
<li><strong>Example Unit Test</strong> &#8211; Example of tracking a simple unit test.</li>
</ul>
<p>Not all code required to communicate with the database is listed in this post. You can either download the source from the project on SourceForge by going to <a href="https://sourceforge.net/projects/seleniumtrack/" target="_blank">https://sourceforge.net/projects/seleniumtrack/</a> or browse the source in the project&#8217;s <a href="http://seleniumtrack.svn.sourceforge.net/viewvc/seleniumtrack/" target="_blank">SVN repository</a>.</p>
<h3>The Back-End Design</h3>
<p>The SQL Server database consists of 5 tables:</p>
<ul>
<li><strong>Test Suite</strong> &#8211; All test suites executed.</li>
<li><strong>UnitTest</strong> &#8211; All unit tests for each test suite.</li>
<li><strong>CommandLog</strong> &#8211; Commands executed for each unit test.</li>
<li><strong>PageLog</strong> &#8211; Page or URL accessed by a command.</li>
<li><strong>Cookies</strong> &#8211; Cookies values, if any, available when viewing a page.</li>
</ul>
<p><div id="attachment_408" class="wp-caption alignnone" style="width: 640px"><a href="http://multitiered.files.wordpress.com/2010/09/tracking-db-schema.jpg"><img src="http://multitiered.files.wordpress.com/2010/09/tracking-db-schema.jpg?w=630&#038;h=137" alt="tracking database schema" title="tracking-db-schema" width="630" height="137" class="size-full wp-image-408" /></a><p class="wp-caption-text">Tracking Database Schema</p></div><br />
&nbsp;</p>
<h3>Core Logic</h3>
<p>There&#8217;s one main class the directs the traffic, <strong>TrackDefaultSelenium</strong>. Inheriting from DefaultSelenium, the commands <strong>start</strong>, <strong>stop</strong>, <strong>open</strong> and <strong>click</strong> are recorded.</p>
<p>It&#8217;s here where test suites and unit test records are saved in the database. For each command targeted at the TrackDefaultSelenium class, records are saved which can be easily tied back to their respective unit tests. </p>
<pre>
<div style="font-family:Courier New;font-size:8pt;color:black;background:none repeat scroll 0 0;margin:0;padding:0;">
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; <span style="color:blue;">public</span> <span style="color:blue;">class</span> <span style="color:#2b91af;">TrackDefaultSelenium</span> : <span style="color:#2b91af;">DefaultSelenium</span>, <span style="color:#2b91af;">ISelenium</span>
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; {
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:blue;">private</span> <span style="color:blue;">string</span> _screenshotPath = <span style="color:#a31515;">@"c:\build\SeleniumTests\Screenshots\"</span>;
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:blue;">private</span> <span style="color:blue;">string</span> _currentUrl;
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:blue;">private</span> <span style="color:blue;">int</span> _testSuiteId;
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:blue;">private</span> <span style="color:blue;">int</span> _unitTestId;
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:blue;">private</span> <span style="color:blue;">bool</span> _captureScreenShots = <span style="color:blue;">false</span>;
<p style="margin:0;padding:0;">&nbsp;
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:blue;">private</span> <span style="color:blue;">string</span> _testSuiteName;
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:blue;">private</span> <span style="color:blue;">string</span> _unitTestName;
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:blue;">public</span> <span style="color:#2b91af;">TestStatus</span> UnitTestStatus { <span style="color:blue;">get</span>; <span style="color:blue;">set</span>; }
<p style="margin:0;padding:0;">&nbsp;
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:blue;">public</span> <span style="color:blue;">enum</span> <span style="color:#2b91af;">TestStatus</span>
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Running,
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Completed,
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Failed
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }
</div>
</pre>
<p><strong>Constructors</strong> &#8211; Kicks off the creation of a test suite.</p>
<pre>
<div style="font-family:Courier New;font-size:8pt;color:black;background:none repeat scroll 0 0;margin:0;padding:0;">
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:blue;">public</span> TrackDefaultSelenium(<span style="color:#2b91af;">ICommandProcessor</span> processor, <span style="color:blue;">string</span> testSuiteName, <span style="color:blue;">string</span> unitTestName, <span style="color:blue;">bool</span> CaptureScreenshots) 
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; : <span style="color:blue;">base</span>(processor) 
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:blue;">this</span>._currentUrl = <span style="color:#a31515;">""</span>;
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:blue;">this</span>._testSuiteName = testSuiteName;
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:blue;">this</span>._unitTestName = unitTestName;
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:blue;">this</span>._captureScreenShots = CaptureScreenshots;
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:blue;">this</span>._testSuiteId = <span style="color:#2b91af;">Tracking</span>.CreateTestSuite(<span style="color:blue;">this</span>._unitSuiteName);
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }
<p style="margin:0;padding:0;">&nbsp;
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:blue;">public</span> TrackDefaultSelenium(<span style="color:blue;">string</span> serverHost, <span style="color:blue;">int</span> serverPort, <span style="color:blue;">string</span> browserString, <span style="color:blue;">string</span> browserURL)
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; : <span style="color:blue;">base</span>(serverHost, serverPort, browserString, browserURL) 
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:blue;">this</span>._currentUrl = <span style="color:#a31515;">""</span>;
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:blue;">this</span>._testSuiteId = <span style="color:#2b91af;">Tracking</span>.CreateTestSuite(<span style="color:blue;">this</span>._unitSuiteName);
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }
</div>
</pre>
<p><strong>Command Overrides</strong> &#8211; <strong>Start</strong> creates the unit test, whereas, <strong>click</strong> and <strong>open</strong> record page hits. </p>
<pre>
<div style="font-family:Courier New;font-size:8pt;color:black;background:none repeat scroll 0 0;margin:0;padding:0;">
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:blue;">void</span> <span style="color:#2b91af;">ISelenium</span>.Start()
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:blue;">this</span>.UnitTestStatus = <span style="color:#2b91af;">TestStatus</span>.Running;
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:blue;">this</span>.commandProcessor.Start();
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:blue;">this</span>._unitTestId = <span style="color:#2b91af;">Tracking</span>.CreateUnitTest(<span style="color:blue;">this</span>._testSuiteId, <span style="color:blue;">this</span>._unitTestName, GetLocation());&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;  
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }
<p style="margin:0;padding:0;">&nbsp;
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:blue;">void</span> <span style="color:#2b91af;">ISelenium</span>.Click(<span style="color:blue;">string</span> locator)
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:blue;">this</span>.commandProcessor.DoCommand(<span style="color:#a31515;">"click"</span>, <span style="color:blue;">new</span> <span style="color:blue;">string</span>[] { locator });
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:blue;">int</span> fileId = RecordPageHit(<span style="color:#a31515;">"click"</span>, GetLocation());
<p style="margin:0;padding:0;">&nbsp;
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:blue;">if</span> (<span style="color:blue;">this</span>._captureScreenShots)
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; CaptureScreenShot(fileId);
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }
<p style="margin:0;padding:0;">&nbsp;
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:blue;">void</span> <span style="color:#2b91af;">ISelenium</span>.Open(<span style="color:blue;">string</span> url)
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:blue;">this</span>.commandProcessor.DoCommand(<span style="color:#a31515;">"open"</span>, <span style="color:blue;">new</span> <span style="color:blue;">string</span>[] { url });
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; RecordPageHit(<span style="color:#a31515;">"open"</span>, GetLocation());
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }
<p style="margin:0;padding:0;">&nbsp;
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:blue;">void</span> <span style="color:#2b91af;">ISelenium</span>.Stop()
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:#2b91af;">Tracking</span>.UpdateUnitTestStatus(<span style="color:blue;">this</span>._unitTestId, UnitTestStatus.ToString());
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:blue;">this</span>.commandProcessor.Stop();
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }
</div>
</pre>
<p><strong>Tracking and Screenshot Capture Methods</strong></p>
<pre>
<div style="font-family:Courier New;font-size:8pt;color:black;background:none repeat scroll 0 0;margin:0;padding:0;">
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:blue;">private</span> <span style="color:blue;">void</span> CaptureScreenShot(<span style="color:blue;">int</span> fileId)
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:blue;">if</span> (!System.IO.<span style="color:#2b91af;">Directory</span>.Exists(<span style="color:blue;">this</span>._screenshotPath + <span style="color:blue;">this</span>._testSuiteId))
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; System.IO.<span style="color:#2b91af;">Directory</span>.CreateDirectory(<span style="color:blue;">this</span>._screenshotPath + <span style="color:blue;">this</span>._testSuiteId);
<p style="margin:0;padding:0;">&nbsp;
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:blue;">if</span> (!System.IO.<span style="color:#2b91af;">Directory</span>.Exists(<span style="color:blue;">this</span>._screenshotPath + <span style="color:blue;">this</span>._testSuiteId + <span style="color:#a31515;">@"\"</span> + <span style="color:blue;">this</span>._unitTestId))
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; System.IO.<span style="color:#2b91af;">Directory</span>.CreateDirectory(<span style="color:blue;">this</span>._screenshotPath + <span style="color:blue;">this</span>._testSuiteId + <span style="color:#a31515;">@"\"</span> + <span style="color:blue;">this</span>._unitTestId);
<p style="margin:0;padding:0;">&nbsp;
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; CaptureEntirePageScreenshot(<span style="color:blue;">this</span>._screenshotPath + <span style="color:blue;">this</span>._testSuiteId + <span style="color:#a31515;">@"\"</span> + <span style="color:blue;">this</span>._unitTestId + <span style="color:#a31515;">@"\"</span> + fileId + <span style="color:#a31515;">@".jpg"</span>, <span style="color:#a31515;">""</span>);
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }
<p style="margin:0;padding:0;">&nbsp;
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:blue;">private</span> <span style="color:blue;">int</span> RecordPageHit(<span style="color:blue;">string</span> command, <span style="color:blue;">string</span> Url)
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:green;">// record the command</span>
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:blue;">int</span> CommandId = <span style="color:#2b91af;">Tracking</span>.CreateCommandLogEntry(<span style="color:blue;">this</span>._unitTestId, command, <span style="color:#a31515;">""</span>);
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:blue;">int</span> PageId = <span style="color:#2b91af;">Tracking</span>.CreatePageLogEntry(CommandId, Url);
<p style="margin:0;padding:0;">&nbsp;
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:green;">// attempt to obtain all cookie values without causing test to fail</span>
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:blue;">string</span> ASPNetSessionId = <span style="color:#a31515;">""</span>;
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:blue;">try</span> { ASPNetSessionId = GetCookieByName(<span style="color:#a31515;">"ASP.NET_SessionId"</span>); } <span style="color:blue;">catch</span> { }
<p style="margin:0;padding:0;">&nbsp;
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:green;">// record all cookie values</span>
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:blue;">if</span> (ASPNetSessionId != <span style="color:#a31515;">""</span>)
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:#2b91af;">Tracking</span>.CreateCookieEntry(PageId, <span style="color:#a31515;">"ASP.NET_SessionId"</span>, ASPNetSessionId);
<p style="margin:0;padding:0;">&nbsp;
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:green;">// save the URL</span>
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:blue;">this</span>._currentUrl = Url;
<p style="margin:0;padding:0;">&nbsp;
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:blue;">return</span> CommandId;
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; }
<p style="margin:0;padding:0;">}
</div>
</pre>
<h3>Example Unit Test</h3>
<p>In this example, we hit a w3school&#8217;s page, check the page title and record every command directed at the Selenium server.</p>
<pre>
<div style="font-family:Courier New;font-size:8pt;color:black;background:none repeat scroll 0 0;margin:0;padding:0;">
<p style="margin:0;padding:0;"><span style="color:blue;">using</span> System;
<p style="margin:0;padding:0;"><span style="color:blue;">using</span> System.Text;
<p style="margin:0;padding:0;"><span style="color:blue;">using</span> System.Text.RegularExpressions;
<p style="margin:0;padding:0;"><span style="color:blue;">using</span> System.Threading;
<p style="margin:0;padding:0;"><span style="color:blue;">using</span> NUnit.Framework;
<p style="margin:0;padding:0;"><span style="color:blue;">using</span> Selenium;
<p style="margin:0;padding:0;"><span style="color:blue;">using</span> Web.Diagnostics.Selenium;
<p style="margin:0;padding:0;">&nbsp;
<p style="margin:0;padding:0;"><span style="color:blue;">namespace</span> Web.Diagnostics.UnitTests.TripPages
<p style="margin:0;padding:0;">{
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; [<span style="color:#2b91af;">TestFixture</span>]
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; <span style="color:blue;">public</span> <span style="color:blue;">class</span> <span style="color:#2b91af;">HeaderMastheadLinks</span> : <span style="color:#2b91af;">TestSuiteBase</span>
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; {
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:blue;">private</span> <span style="color:#2b91af;">ISelenium</span> selenium;
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:blue;">private</span> <span style="color:#2b91af;">StringBuilder</span> verificationErrors;
<p style="margin:0;padding:0;">&nbsp;
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; [<span style="color:#2b91af;">SetUp</span>]
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:blue;">public</span> <span style="color:blue;">void</span> SetupTest()
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:blue;">this</span>.BaseUrl = <span style="color:#a31515;">"http://www.w3schools.com/"</span>;
<p style="margin:0;padding:0;">&nbsp;
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:green;">//target the Selenium RC Server</span>
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; selenium = <span style="color:blue;">new</span> <span style="color:#2b91af;">TrackDefaultSelenium</span>(<span style="color:blue;">new</span> <span style="color:#2b91af;">HttpCommandProcessor</span>(<span style="color:#a31515;">"localhost"</span>, 4444, 
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:#a31515;">"*chrome"</span>, <span style="color:blue;">this</span>.BaseUrl), <span style="color:#a31515;">"Example Test Suite"</span>, <span style="color:#a31515;">"Example Unit Test"</span>, <span style="color:blue;">true</span>);
<p style="margin:0;padding:0;">&nbsp;
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:green;">// test with an anonymous (not logged in, not recognized) user</span>
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; selenium.DeleteAllVisibleCookies();
<p style="margin:0;padding:0;">&nbsp;
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; selenium.Start();
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; verificationErrors = <span style="color:blue;">new</span> <span style="color:#2b91af;">StringBuilder</span>();
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }
<p style="margin:0;padding:0;">&nbsp;
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; [<span style="color:#2b91af;">TearDown</span>]
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:blue;">public</span> <span style="color:blue;">void</span> TeardownTest()
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:blue;">try</span>
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; selenium.Stop();
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:blue;">catch</span> (<span style="color:#2b91af;">Exception</span>)
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:green;">// Ignore errors if unable to close the browser</span>
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:#2b91af;">Assert</span>.AreEqual(<span style="color:#a31515;">""</span>, verificationErrors.ToString());
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }
<p style="margin:0;padding:0;">&nbsp;
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; [<span style="color:#2b91af;">Test</span>]
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:blue;">public</span> <span style="color:blue;">void</span> Header()
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:blue;">try</span>
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; selenium.Open(<span style="color:#a31515;">"http://www.w3schools.com/"</span>);
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; selenium.Click(<span style="color:#a31515;">"link=Learn HTML5"</span>);
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; selenium.WaitForPageToLoad(<span style="color:#a31515;">"30000"</span>);
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:#2b91af;">Assert</span>.AreEqual(<span style="color:#a31515;">"HTML5 Tutorial"</span>, selenium.GetTitle());
<p style="margin:0;padding:0;">&nbsp;
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; (selenium <span style="color:blue;">as</span> <span style="color:#2b91af;">TrackDefaultSelenium</span>).UnitTestStatus = 
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:#2b91af;">TrackDefaultSelenium</span>.<span style="color:#2b91af;">TestStatus</span>.Completed;
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:blue;">catch</span> (<span style="color:#2b91af;">Exception</span> e)
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; (selenium <span style="color:blue;">as</span> <span style="color:#2b91af;">TrackDefaultSelenium</span>).UnitTestStatus = 
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:#2b91af;">TrackDefaultSelenium</span>.<span style="color:#2b91af;">TestStatus</span>.Failed;
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; selenium.Stop();
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:blue;">throw</span> (e);
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; }
<p style="margin:0;padding:0;">}
</div>
</pre>
<p>Notice how the script matches that of one generated by the Firefox plugin. The only difference here is how we&#8217;re instantiating the Selenium object. Instead of using the DefaultSelenium object, we&#8217;re using our custom Selenium tracking object <strong>TrackDefaultSelenium</strong>.</p>
<p>Looking at the data captured from the test above, we get the following:</p>
<p><a href="http://multitiered.files.wordpress.com/2010/09/unittestresults1.jpg"><img src="http://multitiered.files.wordpress.com/2010/09/unittestresults1.jpg?w=630&#038;h=571" alt="UnitTestResults" title="UnitTestResults" width="630" height="571" class="alignnone size-full wp-image-450" /></a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/multitiered.wordpress.com/357/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/multitiered.wordpress.com/357/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/multitiered.wordpress.com/357/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/multitiered.wordpress.com/357/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/multitiered.wordpress.com/357/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/multitiered.wordpress.com/357/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/multitiered.wordpress.com/357/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/multitiered.wordpress.com/357/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/multitiered.wordpress.com/357/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/multitiered.wordpress.com/357/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/multitiered.wordpress.com/357/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/multitiered.wordpress.com/357/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/multitiered.wordpress.com/357/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/multitiered.wordpress.com/357/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=multitiered.wordpress.com&amp;blog=14707195&amp;post=357&amp;subd=multitiered&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://multitiered.wordpress.com/2010/09/13/tracking-selenium-commands-using-c-and-sql-server-2008/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/eb46b0549be16729844d43f494e0f45d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">udpeters</media:title>
		</media:content>

		<media:content url="http://multitiered.files.wordpress.com/2010/09/tracking-db-schema.jpg" medium="image">
			<media:title type="html">tracking-db-schema</media:title>
		</media:content>

		<media:content url="http://multitiered.files.wordpress.com/2010/09/unittestresults1.jpg" medium="image">
			<media:title type="html">UnitTestResults</media:title>
		</media:content>
	</item>
		<item>
		<title>Partial Sitecore Cache Clearing by Item</title>
		<link>http://multitiered.wordpress.com/2010/08/28/partial-sitecore-cache-clearing-by-item/</link>
		<comments>http://multitiered.wordpress.com/2010/08/28/partial-sitecore-cache-clearing-by-item/#comments</comments>
		<pubDate>Sun, 29 Aug 2010 01:48:26 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Sitecore]]></category>
		<category><![CDATA[Cache]]></category>

		<guid isPermaLink="false">http://multitiered.wordpress.com/?p=366</guid>
		<description><![CDATA[Sometimes you just want to clear part of the Sitecore cache and not the entire thing. Taking a page out of the Staging module philosophy, you can easily clear cache by specific items. First, make sure you understand the basics of Sitecore cache and how requests are handled. The example method below, clears an enumerated [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=multitiered.wordpress.com&amp;blog=14707195&amp;post=366&amp;subd=multitiered&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Sometimes you just want to clear part of the Sitecore cache and not the entire thing. Taking a page out of the <a href="http://sdn.sitecore.net/Products/Staging.aspx" target="_blank">Staging module</a> philosophy, you can easily clear cache by specific items. </p>
<p>First, make sure you understand <a href="http://learnsitecore.cmsuniverse.net/en/Developers/Articles/2009/07/CachingOverview.aspx" target="_blank">the basics of Sitecore cache and how requests are handled</a>. </p>
<p>The example method below, clears an enumerated list of items by GUID given a database context.</p>
<pre>
<div style="font-family:Courier New;font-size:8pt;color:black;background:none repeat scroll 0 0;margin:0;padding:0;">
<p style="margin:0;padding:0;"><span style="color:blue;">public</span> <span style="color:blue;">static</span> <span style="color:blue;">void</span> ClearDataItemCache(Database database, IEnumerable ids)
<p style="margin:0;padding:0;">{
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; Cache prefetchCache = GetPrefetchCache(database);
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; <span style="color:blue;">foreach</span> (ID id <span style="color:blue;">in</span> ids)
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; {
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:blue;">if</span> (!ID.IsNullOrEmpty(id))
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; database.Caches.ItemCache.RemoveItem(id);
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; database.Caches.DataCache.RemoveItemInformation(id);
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; database.Caches.StandardValuesCache.RemoveKeysContaining(id.ToString());
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:blue;">if</span> (prefetchCache != <span style="color:blue;">null</span>)
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; prefetchCache.Remove(id);
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; }
<p style="margin:0;padding:0;">}
</div>
</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/multitiered.wordpress.com/366/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/multitiered.wordpress.com/366/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/multitiered.wordpress.com/366/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/multitiered.wordpress.com/366/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/multitiered.wordpress.com/366/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/multitiered.wordpress.com/366/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/multitiered.wordpress.com/366/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/multitiered.wordpress.com/366/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/multitiered.wordpress.com/366/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/multitiered.wordpress.com/366/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/multitiered.wordpress.com/366/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/multitiered.wordpress.com/366/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/multitiered.wordpress.com/366/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/multitiered.wordpress.com/366/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=multitiered.wordpress.com&amp;blog=14707195&amp;post=366&amp;subd=multitiered&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://multitiered.wordpress.com/2010/08/28/partial-sitecore-cache-clearing-by-item/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/eb46b0549be16729844d43f494e0f45d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">udpeters</media:title>
		</media:content>
	</item>
		<item>
		<title>Abandoning the ASP.NET User Session in Sitecore with OMS</title>
		<link>http://multitiered.wordpress.com/2010/08/28/abandoning-the-asp-net-user-session-in-sitecore-with-oms/</link>
		<comments>http://multitiered.wordpress.com/2010/08/28/abandoning-the-asp-net-user-session-in-sitecore-with-oms/#comments</comments>
		<pubDate>Sat, 28 Aug 2010 15:23:36 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Sitecore]]></category>
		<category><![CDATA[Analytics]]></category>

		<guid isPermaLink="false">http://multitiered.wordpress.com/?p=352</guid>
		<description><![CDATA[Be careful when clearing out a user&#8217;s ASP.NET session, if you&#8217;re using Sitecore OMS. If programmatically clearing one&#8217;s session using code similar to one or all of the following: Context.Session.Abandon(); HttpContext.Current.Request.Cookies.Remove("ASP.NET_SessionId"); Response.Cookies.Add(new HttpCookie("ASP.NET_SessionId", string.Empty)); You may notice that in your Sitecore logs, you&#8217;ll have entries that match: &#160;&#160;&#160;&#160;Violation of PRIMARY KEY constraint &#8216;PK_Session_1&#8242;. Cannot insert [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=multitiered.wordpress.com&amp;blog=14707195&amp;post=352&amp;subd=multitiered&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Be careful when clearing out a user&#8217;s ASP.NET session, if you&#8217;re using Sitecore OMS. If programmatically clearing one&#8217;s session using code similar to one or all of the following:</p>
<pre>
<div style="font-family:Courier New;font-size:8pt;color:black;background:none repeat scroll 0 0;margin:0;padding:0;">
<p style="margin:0;padding:0;">Context.Session.Abandon();
<p style="margin:0;padding:0;">HttpContext.Current.Request.Cookies.Remove(<span style="color:#a31515;">"ASP.NET_SessionId"</span>);
<p style="margin:0;padding:0;">Response.Cookies.Add(<span style="color:blue;">new</span> HttpCookie(<span style="color:#a31515;">"ASP.NET_SessionId"</span>, <span style="color:blue;">string</span>.Empty));
</div>
</pre>
<p>You may notice that in your Sitecore logs, you&#8217;ll have entries that match:<br />
<strong><br />
&nbsp;&nbsp;&nbsp;&nbsp;Violation of PRIMARY KEY constraint &#8216;PK_Session_1&#8242;. Cannot insert duplicate key in object &#8216;dbo.Session&#8217;.<br />
</strong></p>
<p>The primary key violation is an indicator that you&#8217;ve cleared out the users ASP.NET session, but neglected to also clear the Analytics Session as well. Since both sessions are so tightly bound in the Analytics data (just take a look at the table schema for the table <strong>Sessions</strong>), breaking this relationship will cause loss of data.</p>
<p>All recording of page events via OMS produce errors for the given session after hitting the piece of code to abandon the ASP.NET session. You lose all Analytics tracking due to this error, which means any pages a user visits after abandoning the ASP.NET session will be lost.</p>
<h3>The Fix</h3>
<p>In addition to clearing the ASP.NET session, also clear the Analytics session:</p>
<pre>
<div style="font-family:Courier New;font-size:8pt;color:black;background:none repeat scroll 0 0;margin:0;padding:0;">
<p style="margin:0;padding:0;">HttpContext.Current.Request.Cookies.Remove(<span style="color:#a31515;">"SC_ANALYTICS_SESSION_COOKIE"</span>);
<p style="margin:0;padding:0;">Response.Cookies.Add(<span style="color:blue;">new</span> HttpCookie(<span style="color:#a31515;">"SC_ANALYTICS_SESSION_COOKIE"</span>, <span style="color:blue;">string</span>.Empty));
</div>
</pre>
<p>Thanks to Sitecore Support for providing the analysis and recommended approach.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/multitiered.wordpress.com/352/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/multitiered.wordpress.com/352/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/multitiered.wordpress.com/352/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/multitiered.wordpress.com/352/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/multitiered.wordpress.com/352/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/multitiered.wordpress.com/352/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/multitiered.wordpress.com/352/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/multitiered.wordpress.com/352/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/multitiered.wordpress.com/352/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/multitiered.wordpress.com/352/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/multitiered.wordpress.com/352/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/multitiered.wordpress.com/352/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/multitiered.wordpress.com/352/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/multitiered.wordpress.com/352/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=multitiered.wordpress.com&amp;blog=14707195&amp;post=352&amp;subd=multitiered&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://multitiered.wordpress.com/2010/08/28/abandoning-the-asp-net-user-session-in-sitecore-with-oms/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/eb46b0549be16729844d43f494e0f45d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">udpeters</media:title>
		</media:content>
	</item>
		<item>
		<title>Running Remote Desktop Console from Command Line</title>
		<link>http://multitiered.wordpress.com/2010/08/20/running-remote-desktop-console-from-command-line/</link>
		<comments>http://multitiered.wordpress.com/2010/08/20/running-remote-desktop-console-from-command-line/#comments</comments>
		<pubDate>Sat, 21 Aug 2010 02:59:03 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Windows Server]]></category>
		<category><![CDATA[Remote Desktop]]></category>

		<guid isPermaLink="false">http://multitiered.wordpress.com/?p=350</guid>
		<description><![CDATA[I always forget the syntax for using Remote Desktop from the command line. mstsc.exe /v:MyPCName /console /f<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=multitiered.wordpress.com&amp;blog=14707195&amp;post=350&amp;subd=multitiered&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I always forget the syntax for using <a href="http://www.howtonetworking.com/RemoteAccess/rdccommand1.htm" target="_blank">Remote Desktop from the command line</a>.</p>
<pre>
mstsc.exe /v:MyPCName /console /f
</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/multitiered.wordpress.com/350/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/multitiered.wordpress.com/350/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/multitiered.wordpress.com/350/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/multitiered.wordpress.com/350/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/multitiered.wordpress.com/350/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/multitiered.wordpress.com/350/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/multitiered.wordpress.com/350/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/multitiered.wordpress.com/350/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/multitiered.wordpress.com/350/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/multitiered.wordpress.com/350/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/multitiered.wordpress.com/350/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/multitiered.wordpress.com/350/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/multitiered.wordpress.com/350/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/multitiered.wordpress.com/350/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=multitiered.wordpress.com&amp;blog=14707195&amp;post=350&amp;subd=multitiered&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://multitiered.wordpress.com/2010/08/20/running-remote-desktop-console-from-command-line/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/eb46b0549be16729844d43f494e0f45d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">udpeters</media:title>
		</media:content>
	</item>
		<item>
		<title>Troubleshooting SMTP Virtual Server Settings in Windows Server 2008</title>
		<link>http://multitiered.wordpress.com/2010/08/18/troubleshooting-smtp-virtual-server-settings-in-windows-server-2008/</link>
		<comments>http://multitiered.wordpress.com/2010/08/18/troubleshooting-smtp-virtual-server-settings-in-windows-server-2008/#comments</comments>
		<pubDate>Thu, 19 Aug 2010 02:31:13 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[IIS]]></category>
		<category><![CDATA[SMTP]]></category>

		<guid isPermaLink="false">http://multitiered.wordpress.com/?p=332</guid>
		<description><![CDATA[One of our development servers today needed to be configured to send emails from our web site to users and staff within the organization. We knew that the application was coded properly, as the email piece was functioning on other servers using the same code base. Within Windows Server 2008, you must first add the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=multitiered.wordpress.com&amp;blog=14707195&amp;post=332&amp;subd=multitiered&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>One of our development servers today needed to be configured to send emails from our web site to users and staff within the organization. We knew that the application was coded properly, as the email piece was functioning on other servers using the same code base. </p>
<p>Within Windows Server 2008, you must first <a href="http://msdn.microsoft.com/en-us/library/8b83ac7t.aspx" target="_blank">add the IIS 6.0 Manager Components</a>. We had this piece installed and configured using the IP of the web server and the default port of 25. Everything looked fine, but for some reason email wasn&#8217;t sending. </p>
<p>What I really needed was a way to troubleshoot the problem. I couldn&#8217;t step through the code, so I needed a way to determine what about the <a href="http://support.microsoft.com/kb/303734" target="_blank">SMTP virtual server message delivery settings</a> were incorrect. I then found a <a href="http://support.microsoft.com/kb/153119" target="_blank">helpful KBA on troubleshooting via telnet</a>.</p>
<p>By using telnet and following the steps in the KBA referenced above, I was able to see at which step during the email process the failure occurred. Making an <strong>EHLO</strong> command, the failure showed a domain different than what I was expecting. Instead of &#8220;oattravel.com&#8221;, I saw the name of the server. Going back into the SMTP virtual server properties, I quickly realized where the problem was.</p>
<p>The <strong>SMTP Advanced Delivery Options</strong> required domains for both:</p>
<ul>
<li>Masquerade domain</li>
<li>Fully-qualified domain name</li>
</ul>
<p><a href="http://multitiered.files.wordpress.com/2010/08/smtp-advanced-delivery-options1.jpg"><img src="http://multitiered.files.wordpress.com/2010/08/smtp-advanced-delivery-options1.jpg?w=627&#038;h=468" alt="" title="SMTP-Advanced-Delivery-Options" width="627" height="468" class="alignnone size-full wp-image-338" /></a></p>
<p>After changing the settings above, then retracing the steps to telnet back into the server and send an email, I then got a successful <strong>&#8220;Queued message for delivery&#8221;</strong> status. </p>
<p><a href="http://multitiered.files.wordpress.com/2010/08/telnet-test-smpt-settings-blur.jpg"><img src="http://multitiered.files.wordpress.com/2010/08/telnet-test-smpt-settings-blur.jpg?w=630&#038;h=445" alt="Telnet test SMTP settings blur" title="Telnet-Test-SMPT-Settings-Blur" width="630" height="445" class="alignnone size-full wp-image-334" /></a></p>
<p>One last note&#8230; make sure your SMTP Service is set to start up automatically. Ours wasn&#8217;t. For every IISRESET, the SMTP virtual server would stop and remain stopped until manually started again.</p>
<div id="attachment_341" class="wp-caption alignnone" style="width: 640px"><a href="http://multitiered.files.wordpress.com/2010/08/smtp-service-automatic-startup.jpg"><img src="http://multitiered.files.wordpress.com/2010/08/smtp-service-automatic-startup.jpg?w=630&#038;h=139" alt="SMTP Service Automatic Startup" title="SMTP-Service-Automatic-Startup" width="630" height="139" class="size-full wp-image-341" /></a><p class="wp-caption-text">Set the SMTP Service to automatic startup</p></div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/multitiered.wordpress.com/332/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/multitiered.wordpress.com/332/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/multitiered.wordpress.com/332/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/multitiered.wordpress.com/332/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/multitiered.wordpress.com/332/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/multitiered.wordpress.com/332/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/multitiered.wordpress.com/332/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/multitiered.wordpress.com/332/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/multitiered.wordpress.com/332/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/multitiered.wordpress.com/332/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/multitiered.wordpress.com/332/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/multitiered.wordpress.com/332/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/multitiered.wordpress.com/332/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/multitiered.wordpress.com/332/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=multitiered.wordpress.com&amp;blog=14707195&amp;post=332&amp;subd=multitiered&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://multitiered.wordpress.com/2010/08/18/troubleshooting-smtp-virtual-server-settings-in-windows-server-2008/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/eb46b0549be16729844d43f494e0f45d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">udpeters</media:title>
		</media:content>

		<media:content url="http://multitiered.files.wordpress.com/2010/08/smtp-advanced-delivery-options1.jpg" medium="image">
			<media:title type="html">SMTP-Advanced-Delivery-Options</media:title>
		</media:content>

		<media:content url="http://multitiered.files.wordpress.com/2010/08/telnet-test-smpt-settings-blur.jpg" medium="image">
			<media:title type="html">Telnet-Test-SMPT-Settings-Blur</media:title>
		</media:content>

		<media:content url="http://multitiered.files.wordpress.com/2010/08/smtp-service-automatic-startup.jpg" medium="image">
			<media:title type="html">SMTP-Service-Automatic-Startup</media:title>
		</media:content>
	</item>
		<item>
		<title>Why Can&#8217;t I Copy Assemblies from the GAC?</title>
		<link>http://multitiered.wordpress.com/2010/08/17/why-cant-i-copy-assemblies-from-the-gac/</link>
		<comments>http://multitiered.wordpress.com/2010/08/17/why-cant-i-copy-assemblies-from-the-gac/#comments</comments>
		<pubDate>Wed, 18 Aug 2010 02:15:40 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Windows Server]]></category>
		<category><![CDATA[GAC]]></category>
		<category><![CDATA[Web.Config]]></category>

		<guid isPermaLink="false">http://multitiered.wordpress.com/?p=318</guid>
		<description><![CDATA[Today, I needed to obtain a copy of an assembly referenced in a web.config of one of our applications. The assembly referenced resembled the following: &#60;assemblies&#62; &#160; &#60;add assembly="Oracle.DataAccess, Version=10.1.0.200, Culture=neutral, PublicKeyToken=89B483F429C47342"/&#62; &#60;/assemblies&#62; I tried making a copy of an assembly from the GAC to my file system. Simple task, right? That&#8217;s what I thought [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=multitiered.wordpress.com&amp;blog=14707195&amp;post=318&amp;subd=multitiered&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Today, I needed to obtain a copy of an assembly referenced in a web.config of one of our applications. The assembly referenced resembled the following:</p>
<pre>
<div style="font-family:Courier New;font-size:8pt;color:black;background:none repeat scroll 0 0;margin:0;padding:0;">
<p style="margin:0;padding:0;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">assemblies</span><span style="color:blue;">&gt;</span>
<p style="margin:0;padding:0;"><span style="color:blue;">&nbsp; &lt;</span><span style="color:#a31515;">add</span><span style="color:blue;"> </span><span style="color:red;">assembly</span><span style="color:blue;">=</span>"<span style="color:blue;">Oracle.DataAccess, Version=10.1.0.200, Culture=neutral, PublicKeyToken=89B483F429C47342</span>"<span style="color:blue;">/&gt;</span>
<p style="margin:0;padding:0;"><span style="color:blue;">&lt;/</span><span style="color:#a31515;">assemblies</span><span style="color:blue;">&gt;</span>
</div>
</pre>
<p></p>
<p>I tried making a copy of an assembly from the GAC to my file system. Simple task, right? That&#8217;s what I thought until I right-clicked on a file only to find a few options, none of which had &#8220;copy&#8221;.</p>
<p><a href="http://multitiered.files.wordpress.com/2010/08/cannot-copy-file-from-explorer1.jpg"><img src="http://multitiered.files.wordpress.com/2010/08/cannot-copy-file-from-explorer1.jpg?w=574&#038;h=494" alt="cannot copy file from explorer" title="cannot-copy-file-from-explorer" width="574" height="494" class="alignnone size-full wp-image-327" /></a></p>
<p>After googling around, I discovered that I had <a href="https://blogs.msdn.com/b/johnwpowell/archive/2009/01/14/how-to-copy-an-assembly-from-the-gac.aspx" target="_blank">a few options</a>. I opted to copy from the command line:</p>
<p><a href="http://multitiered.files.wordpress.com/2010/08/copy-assembly-from-command-line.jpg"><img src="http://multitiered.files.wordpress.com/2010/08/copy-assembly-from-command-line.jpg?w=630&#038;h=312" alt="copy assembly from the command line" title="copy-assembly-from-command-line" width="630" height="312" class="alignnone size-full wp-image-320" /></a></p>
<p>By going into the GAC assembly directory from the command line and drilling deeper into the directory tree, you will eventually find the DLL you&#8217;re looking for.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/multitiered.wordpress.com/318/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/multitiered.wordpress.com/318/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/multitiered.wordpress.com/318/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/multitiered.wordpress.com/318/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/multitiered.wordpress.com/318/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/multitiered.wordpress.com/318/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/multitiered.wordpress.com/318/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/multitiered.wordpress.com/318/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/multitiered.wordpress.com/318/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/multitiered.wordpress.com/318/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/multitiered.wordpress.com/318/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/multitiered.wordpress.com/318/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/multitiered.wordpress.com/318/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/multitiered.wordpress.com/318/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=multitiered.wordpress.com&amp;blog=14707195&amp;post=318&amp;subd=multitiered&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://multitiered.wordpress.com/2010/08/17/why-cant-i-copy-assemblies-from-the-gac/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/eb46b0549be16729844d43f494e0f45d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">udpeters</media:title>
		</media:content>

		<media:content url="http://multitiered.files.wordpress.com/2010/08/cannot-copy-file-from-explorer1.jpg" medium="image">
			<media:title type="html">cannot-copy-file-from-explorer</media:title>
		</media:content>

		<media:content url="http://multitiered.files.wordpress.com/2010/08/copy-assembly-from-command-line.jpg" medium="image">
			<media:title type="html">copy-assembly-from-command-line</media:title>
		</media:content>
	</item>
		<item>
		<title>Sitecore OMS Error: Overwhelming Change Notification</title>
		<link>http://multitiered.wordpress.com/2010/08/11/sitecore-oms-error-overwhelming-change-notification/</link>
		<comments>http://multitiered.wordpress.com/2010/08/11/sitecore-oms-error-overwhelming-change-notification/#comments</comments>
		<pubDate>Thu, 12 Aug 2010 00:24:49 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Sitecore]]></category>
		<category><![CDATA[Analytics]]></category>
		<category><![CDATA[IIS]]></category>

		<guid isPermaLink="false">http://multitiered.wordpress.com/?p=285</guid>
		<description><![CDATA[Today, our websites generated a stack trace error with an &#8220;Out of Memory Exception&#8221; message for the whole world to see. Immediately looking at the IIS logs, we discovered 500 internal server errors over a 3-minute time span. Using the time stamp generated by IIS, I then compared against the error logs created by Sitecore [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=multitiered.wordpress.com&amp;blog=14707195&amp;post=285&amp;subd=multitiered&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Today, our websites generated a stack trace error with an &#8220;Out of Memory Exception&#8221; message for the whole world to see.</p>
<p>Immediately looking at the IIS logs, we discovered 500 internal server errors over a 3-minute time span. Using the time stamp generated by IIS, I then compared against the error logs created by Sitecore (typically in <strong>[website path]\data\logs</strong>).</p>
<p>Looking at the Sitecore logs, sandwiched between two Analytics errors, I see the following:</p>
<pre>4304 14:29:31 ERROR Failed to insert Analytics data
Exception: System.Data.SqlClient.SqlException
...
<span style="color:red;">
4276 14:30:18 INFO  **************************************************
4276 14:30:18 WARN  Sitecore shutting down
4276 14:30:18 WARN  Shutdown message: Overwhelming Change Notification in C:\inetpub\wwwroot
Overwhelming Change Notification in C:\inetpub\wwwroot
Change in GLOBAL.ASAX
HostingEnvironment initiated shutdown
CONFIG change
</span>
4304 14:30:26 ERROR Failed to insert Analytics data
Exception: System.Data.SqlClient.SqlException
...</pre>
<p>Having no idea what <strong>&#8220;Overwhelming change notification&#8221;</strong> meant of what it was referring to, our team contacted Sitecore directly. Turns out that this error is a result of a bug in OMS 1.0.1 (running under Sitecore 6.1). An unhandled exception appeared in the Sitecore OMS module due to improper handling of the AnalyticsLogger class. Their support team were able to reproduce the issue and generate the following error message related to the one triggered above:</p>
<pre>ERROR Unhandled exception detected. The ASP.NET worker process will be terminated.
Exception: System.IndexOutOfRangeException
Message: Index was outside the bounds of the array.
Source: mscorlib
   at System.Collections.Generic.List`1.Add(T item)
. . .</pre>
<p>Currently, the only work around for this is to disable error logging for Sitecore OMS by following the steps below:<br />
<strong></p>
<ol>
<li>Open the \Website\App_Config\Include\Sitecore.Analytics.config file.</li>
<li> In Sitecore.Analytics.config file, comment the following pipeline’s processor:<br />
<br />
	&lt;!&#8211; &lt;processor type=&#8221;Sitecore.Analytics.</p>
<div id=":ui">Pipelines.HttpRequest.StartDiagnostics, Sitecore.Analytics&#8221; patch:after=&#8221;processor[@type='Sitecore.Pipelines.HttpRequest.StartMeasurements, Sitecore.Kernel']&#8221; /&gt; &#8211;&gt;</li>
</ol>
<p></strong>Tough choice here&#8230;. Keep your OMS error logging or take your chances with random OMS exceptions?</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/multitiered.wordpress.com/285/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/multitiered.wordpress.com/285/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/multitiered.wordpress.com/285/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/multitiered.wordpress.com/285/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/multitiered.wordpress.com/285/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/multitiered.wordpress.com/285/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/multitiered.wordpress.com/285/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/multitiered.wordpress.com/285/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/multitiered.wordpress.com/285/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/multitiered.wordpress.com/285/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/multitiered.wordpress.com/285/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/multitiered.wordpress.com/285/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/multitiered.wordpress.com/285/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/multitiered.wordpress.com/285/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=multitiered.wordpress.com&amp;blog=14707195&amp;post=285&amp;subd=multitiered&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://multitiered.wordpress.com/2010/08/11/sitecore-oms-error-overwhelming-change-notification/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/eb46b0549be16729844d43f494e0f45d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">udpeters</media:title>
		</media:content>
	</item>
		<item>
		<title>Getting Started with the Facebook C# SDK</title>
		<link>http://multitiered.wordpress.com/2010/08/05/getting-started-with-the-facebook-c-sharp-sdk/</link>
		<comments>http://multitiered.wordpress.com/2010/08/05/getting-started-with-the-facebook-c-sharp-sdk/#comments</comments>
		<pubDate>Thu, 05 Aug 2010 04:37:11 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Social Networks]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Facebook]]></category>
		<category><![CDATA[JSON]]></category>

		<guid isPermaLink="false">http://multitiered.wordpress.com/?p=216</guid>
		<description><![CDATA[Facebook recently announced the release of the Facebook C# SDK. The SDK allows .NET developers to create Facebook applications by directly calling their API. To get started with the SDK, follow these steps: Download the source and build the FacebookAPI project. Create your Facebook application from the Developer Section of your Facebook profile&#8217;s Application Settings. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=multitiered.wordpress.com&amp;blog=14707195&amp;post=216&amp;subd=multitiered&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Facebook <a href="http://developers.facebook.com/blog/post/395" target="_blank">recently announced the release of the Facebook C# SDK</a>. The SDK allows .NET developers to create Facebook applications by directly calling their API. To get started with the SDK, follow these steps:</p>
<ol>
<li>Download the source and build the FacebookAPI project.</li>
<li>Create your Facebook application from the <strong>Developer Section</strong> of your Facebook profile&#8217;s <strong>Application Settings</strong>.</li>
<li>Coding your application to use the FacebookAPI.</li>
</ol>
<p>In this example, I&#8217;ll demonstrate the creation of a simple .NET application that communicates with Facebook to pull my profile and friends list. </p>
<h3>Building the FacebookAPI Project</h3>
<p>First, <a href="http://github.com/facebook/csharp-sdk" target="_blank">download the source of the Facebook API project</a>. Open the solution <strong>FacebookAPI.sln</strong> in Visual Studio and build the project. You will later use Facebook API assembly to interact with Facebook via .NET.</p>
<h3>Creating the Application on Facebook</h3>
<p>In order to successfully make calls to Facebook, you have to first <a href="http://developers.facebook.com/setup/" target="_blank">register your application</a> with Facebook and obtain authentication keys to be used with <a href="http://tools.ietf.org/html/draft-ietf-oauth-v2-10" target="_blank">OAuth 2.0</a>.</p>
<p>1. Go to <a href="http://developers.facebook.com/setup/" target="_blank">http://developers.facebook.com/setup/</a> to begin registering your application. Make sure you use Internet Explorer. I ran into problems when attempting to register using Firefox (application would register, but a blank page was displayed).</p>
<p>2. Register the application using a site name and URL of the path relative to your authenticating logic. The <strong>redirect_url</strong> parameter you provide to the <a href="http://developers.facebook.com/docs/api" target="_blank">Facebook Graph API</a> needs to match the path used to register the application.</p>
<p><a href="http://multitiered.files.wordpress.com/2010/08/create-facebook-application.jpg"><img src="http://multitiered.files.wordpress.com/2010/08/create-facebook-application.jpg?w=504&#038;h=308" alt="create facebook application" title="create facebook application" width="504" height="308" class="alignnone size-full wp-image-231" /></a></p>
<p>In this example, I&#8217;ve registered the application as:</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;<strong>Site Name:</strong> Dave Test<br />
&nbsp;&nbsp;&nbsp;&nbsp;<strong>Site URL:</strong> http://localhost/Facebook/oauth/</p>
<p>3. Once registered, you can view your application&#8217;s configuration settings and authentication keys. These details will be referenced in the example code to make requests to Facebook.</p>
<p><a href="http://multitiered.files.wordpress.com/2010/08/my-application-overview.jpg"><img src="http://multitiered.files.wordpress.com/2010/08/my-application-overview.jpg?w=630&#038;h=572" alt="my application overview" title="my application overview" width="630" height="572" class="alignnone size-full wp-image-234" /></a></p>
<h3>Coding the Application</h3>
<p>To accomplish the task of pulling my Facebook profile and friends list, I need to do the following:</p>
<ul>
<li>Redirect from my local web application to Facebook with my application id and URL of my redirect handler</li>
<li>Construct the redirect URL handler to accept the access token provided by Facebook</li>
<li>Instantiate the FacebookAPI object with the access token above</li>
<li>Access my Profile via the FacebookAPI</li>
</ul>
<p><strong>1. Redirecting to Facebook</strong></p>
<p>We need to send Facebook our application id and URL of the handler for Facebook&#8217;s redirect, containing our access token. </p>
<pre>
<div style="font-family:Courier New;font-size:8pt;color:black;background:none repeat scroll 0 0;margin:0;padding:0;">
<p style="margin:0;padding:0;"><span style="color:blue;">protected</span> <span style="color:blue;">void</span> btnAuthenticate_Click(<span style="color:blue;">object</span> sender, <span style="color:#2b91af;">EventArgs</span> e)
<p style="margin:0;padding:0;">{
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; <span style="color:blue;">string</span> clientId = <span style="color:#a31515;">"117342178314989"</span>;
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; <span style="color:blue;">string</span> redirectUrl = <span style="color:#a31515;">"http://localhost/Facebook/oauth/oauth-redirect.aspx"</span>;
<p style="margin:0;padding:0;">&nbsp;
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; Response.Redirect(<span style="color:blue;">string</span>.Format(<span style="color:#a31515;">"https://graph.facebook.com/oauth/authorize?client_id={0}&amp;redirect_uri={1}"</span>, clientId, redirectUrl));
<p style="margin:0;padding:0;">}
</div>
</pre>
<p>Notice that the variable <strong>clientId</strong> matches the field <strong>Application Id</strong> in my Facebook Application configuration settings and the relative path in the variable <strong>redirectUrl</strong> matches the path defined in the field <strong>Connect URL</strong>. </p>
<p>After redirecting, a response is sent back to <strong>http://localhost/Facebook/oauth/oauth-redirect.aspx</strong> containing a code in the query string parameters of the URL. Successfully making a call, results in the following URL: </p>
<pre>
<strong>http://localhost/Facebook/oauth/oauth-redirect.aspx?code=2.UwNcNB5FfO69d_l5S1j76Q__.3600.1280984400-1427490881%7CGE2JRQaeMDwAZHwZMkk0NUiMQD4.
</strong>
</pre>
<p>Notice the parameter <strong>code</strong>. This value will be used to request an access token from Facebook&#8217;s Graph API.</p>
<p><strong>2. Building the Handler for Facebook&#8217;s Redirect</strong></p>
<p>In step 1, we&#8217;ve created the request to Facebook. In step 2, we need to build the handler to accept the access token provided by Facebook to successfully make API calls. </p>
<p>Currently, there&#8217;s nothing built into the API that requests the access token, so I had to build one. The code below calls the Facebook Graph API, requesting an access token. </p>
<pre>
<div style="font-family:Courier New;font-size:8pt;color:black;background:none repeat scroll 0 0;margin:0;padding:0;">
<p style="margin:0;padding:0;"><span style="color:blue;">private</span> <span style="color:#2b91af;">Dictionary</span>&lt;<span style="color:blue;">string</span>, <span style="color:blue;">string</span>&gt; GetOauthTokens(<span style="color:blue;">string</span> code)
<p style="margin:0;padding:0;">{
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; <span style="color:#2b91af;">Dictionary</span>&lt;<span style="color:blue;">string</span>, <span style="color:blue;">string</span>&gt; tokens = <span style="color:blue;">new</span> <span style="color:#2b91af;">Dictionary</span>&lt;<span style="color:blue;">string</span>, <span style="color:blue;">string</span>&gt;();
<p style="margin:0;padding:0;">&nbsp;
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; <span style="color:blue;">string</span> clientId = <span style="color:#a31515;">"117342178314989"</span>;
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; <span style="color:blue;">string</span> redirectUrl = <span style="color:#a31515;">"http://localhost/Facebook/oauth/oauth-redirect.aspx"</span>;
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; <span style="color:blue;">string</span> clientSecret = <span style="color:#a31515;">"bc7996cfc4f0c66d0417b54eea73f4e7"</span>;
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; <span style="color:blue;">string</span> scope = <span style="color:#a31515;">"read_friendlists,user_status"</span>;
<p style="margin:0;padding:0;">&nbsp;
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; <span style="color:blue;">string</span> url = <span style="color:blue;">string</span>.Format(<span style="color:#a31515;">"https://graph.facebook.com/oauth/access_token?client_id={0}&amp;redirect_uri={1}&amp;client_secret={2}&amp;code={3}&amp;scope={4}"</span>,
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; clientId, redirectUrl, clientSecret, code, scope);
<p style="margin:0;padding:0;">&nbsp;
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; <span style="color:#2b91af;">HttpWebRequest</span> request = <span style="color:#2b91af;">WebRequest</span>.Create(url) <span style="color:blue;">as</span> <span style="color:#2b91af;">HttpWebRequest</span>;
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; <span style="color:blue;">using</span> (<span style="color:#2b91af;">HttpWebResponse</span> response = request.GetResponse() <span style="color:blue;">as</span> <span style="color:#2b91af;">HttpWebResponse</span>)
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; {
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:#2b91af;">StreamReader</span> reader = <span style="color:blue;">new</span> <span style="color:#2b91af;">StreamReader</span>(response.GetResponseStream());
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:blue;">string</span> retVal = reader.ReadToEnd();
<p style="margin:0;padding:0;">&nbsp;
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:blue;">foreach</span> (<span style="color:blue;">string</span> token <span style="color:blue;">in</span> retVal.Split(<span style="color:#a31515;">'&amp;'</span>))
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; tokens.Add(token.Substring(0, token.IndexOf(<span style="color:#a31515;">"="</span>)),
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; token.Substring(token.IndexOf(<span style="color:#a31515;">"="</span>) + 1, token.Length - token.IndexOf(<span style="color:#a31515;">"="</span>) - 1));
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; }
<p style="margin:0;padding:0;">&nbsp;
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; <span style="color:blue;">return</span> tokens;
<p style="margin:0;padding:0;">}
</div>
</pre>
<p>Variables <strong>clientId</strong> and <strong>clientSecret</strong> should match fields <strong>Application Id</strong> and <strong>Application Secret</strong>, respectively, in the Facebook Application Settings page. </p>
<p><strong>Scope</strong> defines the scope of the request. These values are considered <a href="http://developers.facebook.com/docs/authentication/permissions" target="_blank">Extended Permissions</a> which means requesting access to data not marked as public to everyone in a user&#8217;s Facebook profile. </p>
<p><strong>3. Instantiate FacebookAPI with an Access Token</strong></p>
<p>The method <strong>GetOauthTokens</strong> accepts a parameter <strong>code</strong>. We&#8217;ll pass in the code value obtained in the query string param of the response in step 1 and cache the response for the time defined by the expiration value in Facebook&#8217;s Graph API response. </p>
<pre>
<div style="font-family:Courier New;font-size:8pt;color:black;background:none repeat scroll 0 0;margin:0;padding:0;">
<p style="margin:0;padding:0;"><span style="color:blue;">protected</span> <span style="color:blue;">void</span> Page_Load(<span style="color:blue;">object</span> sender, <span style="color:#2b91af;">EventArgs</span> e)
<p style="margin:0;padding:0;">{
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; <span style="color:blue;">if</span> (Request.Params[<span style="color:#a31515;">"code"</span>] != <span style="color:blue;">null</span>)
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; {
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Facebook.<span style="color:#2b91af;">FacebookAPI</span> api = <span style="color:blue;">new</span> Facebook.<span style="color:#2b91af;">FacebookAPI</span>(GetAccessToken());
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ...
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; }
<p style="margin:0;padding:0;">}
<p style="margin:0;padding:0;">&nbsp;
<p style="margin:0;padding:0;"><span style="color:blue;">private</span> <span style="color:blue;">string</span> GetAccessToken()
<p style="margin:0;padding:0;">{
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; <span style="color:blue;">if</span> (<span style="color:#2b91af;">HttpRuntime</span>.Cache[<span style="color:#a31515;">"access_token"</span>] == <span style="color:blue;">null</span>)
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; {
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:#2b91af;">Dictionary</span>&lt;<span style="color:blue;">string</span>, <span style="color:blue;">string</span>&gt; args = GetOauthTokens(Request.Params[<span style="color:#a31515;">"code"</span>]);
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:#2b91af;">HttpRuntime</span>.Cache.Insert(<span style="color:#a31515;">"access_token"</span>, args[<span style="color:#a31515;">"access_token"</span>], <span style="color:blue;">null</span>, <span style="color:#2b91af;">DateTime</span>.Now.AddMinutes(<span style="color:#2b91af;">Convert</span>.ToDouble(args[<span style="color:#a31515;">"expires"</span>])), <span style="color:#2b91af;">TimeSpan</span>.Zero);
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; }
<p style="margin:0;padding:0;">&nbsp;
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; <span style="color:blue;">return</span> <span style="color:#2b91af;">HttpRuntime</span>.Cache[<span style="color:#a31515;">"access_token"</span>].ToString();
<p style="margin:0;padding:0;">}
</div>
</pre>
<p><strong>4. Access My Facebook Profile</strong></p>
<p>Now that we have an active connection with Facebook, we can use the API in step 3 to request my profile information. Doing so is as easy as a few lines of code:</p>
<pre>
<div style="font-family:Courier New;font-size:8pt;color:black;background:none repeat scroll 0 0;margin:0;padding:0;">
<p style="margin:0;padding:0;"><span style="color:#2b91af;">JSONObject</span> me = api.Get(<span style="color:#a31515;">"/me"</span>);
<p style="margin:0;padding:0;"><span style="color:#2b91af;">JSONObject</span> meFriends = api.Get(<span style="color:#a31515;">"/me/friends"</span>);
</div>
</pre>
<p>making <strong>Get</strong> requests to Facebook via the API returns JSON containing profile information. The first requests my profile while the second obtains my friends list.</p>
<p>Placing a watch on these objects gives us<br />
<a href="http://multitiered.files.wordpress.com/2010/08/watch-me.jpg"><img src="http://multitiered.files.wordpress.com/2010/08/watch-me.jpg?w=630&#038;h=341" alt="a watch on me" title="watch me" width="630" height="341" class="size-full wp-image-255" /></a></p>
<a href="http://multitiered.files.wordpress.com/2010/08/watch-me-friends.jpg"><img src="http://multitiered.files.wordpress.com/2010/08/watch-me-friends.jpg?w=630&#038;h=646" alt="a watch of variable meFriends" title="watch me friends" width="630" height="646" class="size-full wp-image-256" /></a>
<p>
As you can see, the variable <strong>me</strong> contains all of my public profile attributes. The variable <strong>meFriends</strong> has all 188 of my friends in an array of dictionary items. Each friend is stored in an id/name combo. If we wanted, we could take this another level deeper and get all friends profiles by requesting the id via the Graph API like so (1427490881 is my Facebook id):</p>
<pre>
<div style="font-family:Courier New;font-size:8pt;color:black;background:none repeat scroll 0 0;margin:0;padding:0;">
<p style="margin:0;padding:0;"><span style="color:#2b91af;">JSONObject</span> me = api.Get(<span style="color:#a31515;">"/1427490881"</span>);
</div>
</pre>
<h3>Full Source</h3>
<h4>/Default.aspx.cs</h4>
<pre>
<div style="font-family:Courier New;font-size:8pt;color:black;background:none repeat scroll 0 0;margin:0;padding:0;">
<p style="margin:0;padding:0;"><span style="color:blue;">using</span> System;
<p style="margin:0;padding:0;"><span style="color:blue;">using</span> System.Collections;
<p style="margin:0;padding:0;"><span style="color:blue;">using</span> System.Configuration;
<p style="margin:0;padding:0;"><span style="color:blue;">using</span> System.Data;
<p style="margin:0;padding:0;"><span style="color:blue;">using</span> System.Linq;
<p style="margin:0;padding:0;"><span style="color:blue;">using</span> System.Web;
<p style="margin:0;padding:0;"><span style="color:blue;">using</span> System.Web.Security;
<p style="margin:0;padding:0;"><span style="color:blue;">using</span> System.Web.UI;
<p style="margin:0;padding:0;"><span style="color:blue;">using</span> System.Web.UI.HtmlControls;
<p style="margin:0;padding:0;"><span style="color:blue;">using</span> System.Web.UI.WebControls;
<p style="margin:0;padding:0;"><span style="color:blue;">using</span> System.Web.UI.WebControls.WebParts;
<p style="margin:0;padding:0;"><span style="color:blue;">using</span> System.Xml.Linq;
<p style="margin:0;padding:0;">&nbsp;
<p style="margin:0;padding:0;"><span style="color:blue;">namespace</span> Facebook
<p style="margin:0;padding:0;">{
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; <span style="color:blue;">public</span> <span style="color:blue;">partial</span> <span style="color:blue;">class</span> <span style="color:#2b91af;">_Default</span> : System.Web.UI.<span style="color:#2b91af;">Page</span>
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; {
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:blue;">protected</span> <span style="color:blue;">void</span> btnAuthenticate_Click(<span style="color:blue;">object</span> sender, <span style="color:#2b91af;">EventArgs</span> e)
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:blue;">string</span> clientId = <span style="color:#a31515;">"117342178314989"</span>;
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:blue;">string</span> redirectUrl = <span style="color:#a31515;">"http://localhost/Facebook/oauth/oauth-redirect.aspx"</span>;
<p style="margin:0;padding:0;">&nbsp;
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Response.Redirect(<span style="color:blue;">string</span>.Format(<span style="color:#a31515;">"https://graph.facebook.com/oauth/authorize?client_id={0}&amp;redirect_uri={1}"</span>, clientId, redirectUrl));
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; }
<p style="margin:0;padding:0;">}
</div>
</pre>
<h4>/oauth/oauth-redirect.aspx.cs</h4>
<pre>
<div style="font-family:Courier New;font-size:8pt;color:black;background:none repeat scroll 0 0;margin:0;padding:0;">
<p style="margin:0;padding:0;"><span style="color:blue;">using</span> System;
<p style="margin:0;padding:0;"><span style="color:blue;">using</span> System.Collections;
<p style="margin:0;padding:0;"><span style="color:blue;">using</span> System.Configuration;
<p style="margin:0;padding:0;"><span style="color:blue;">using</span> System.Data;
<p style="margin:0;padding:0;"><span style="color:blue;">using</span> System.Linq;
<p style="margin:0;padding:0;"><span style="color:blue;">using</span> System.Web;
<p style="margin:0;padding:0;"><span style="color:blue;">using</span> System.Web.Security;
<p style="margin:0;padding:0;"><span style="color:blue;">using</span> System.Web.UI;
<p style="margin:0;padding:0;"><span style="color:blue;">using</span> System.Web.UI.HtmlControls;
<p style="margin:0;padding:0;"><span style="color:blue;">using</span> System.Web.UI.WebControls;
<p style="margin:0;padding:0;"><span style="color:blue;">using</span> System.Web.UI.WebControls.WebParts;
<p style="margin:0;padding:0;"><span style="color:blue;">using</span> System.Xml.Linq;
<p style="margin:0;padding:0;"><span style="color:blue;">using</span> Facebook;
<p style="margin:0;padding:0;"><span style="color:blue;">using</span> System.IO;
<p style="margin:0;padding:0;"><span style="color:blue;">using</span> System.Net;
<p style="margin:0;padding:0;"><span style="color:blue;">using</span> System.Collections.Generic;
<p style="margin:0;padding:0;">&nbsp;
<p style="margin:0;padding:0;"><span style="color:blue;">namespace</span> Facebook
<p style="margin:0;padding:0;">{
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; <span style="color:blue;">public</span> <span style="color:blue;">partial</span> <span style="color:blue;">class</span> <span style="color:#2b91af;">oauth_redirect</span> : System.Web.UI.<span style="color:#2b91af;">Page</span>
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; {
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:blue;">protected</span> <span style="color:blue;">void</span> Page_Load(<span style="color:blue;">object</span> sender, <span style="color:#2b91af;">EventArgs</span> e)
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:blue;">if</span> (Request.Params[<span style="color:#a31515;">"code"</span>] != <span style="color:blue;">null</span>)
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Facebook.<span style="color:#2b91af;">FacebookAPI</span> api = <span style="color:blue;">new</span> Facebook.<span style="color:#2b91af;">FacebookAPI</span>(GetAccessToken());
<p style="margin:0;padding:0;">&nbsp;
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:#2b91af;">JSONObject</span> me = api.Get(<span style="color:#a31515;">"/me"</span>);
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:#2b91af;">JSONObject</span> meFriends = api.Get(<span style="color:#a31515;">"/me/friends"</span>);
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }
<p style="margin:0;padding:0;">&nbsp;
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:blue;">private</span> <span style="color:blue;">string</span> GetAccessToken()
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:blue;">if</span> (<span style="color:#2b91af;">HttpRuntime</span>.Cache[<span style="color:#a31515;">"access_token"</span>] == <span style="color:blue;">null</span>)
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:#2b91af;">Dictionary</span>&lt;<span style="color:blue;">string</span>, <span style="color:blue;">string</span>&gt; args = GetOauthTokens(Request.Params[<span style="color:#a31515;">"code"</span>]);
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:#2b91af;">HttpRuntime</span>.Cache.Insert(<span style="color:#a31515;">"access_token"</span>, args[<span style="color:#a31515;">"access_token"</span>], <span style="color:blue;">null</span>, <span style="color:#2b91af;">DateTime</span>.Now.AddMinutes(<span style="color:#2b91af;">Convert</span>.ToDouble(args[<span style="color:#a31515;">"expires"</span>])), <span style="color:#2b91af;">TimeSpan</span>.Zero);
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }
<p style="margin:0;padding:0;">&nbsp;
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:blue;">return</span> <span style="color:#2b91af;">HttpRuntime</span>.Cache[<span style="color:#a31515;">"access_token"</span>].ToString();
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }
<p style="margin:0;padding:0;">&nbsp;
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:blue;">private</span> <span style="color:#2b91af;">Dictionary</span>&lt;<span style="color:blue;">string</span>, <span style="color:blue;">string</span>&gt; GetOauthTokens(<span style="color:blue;">string</span> code)
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:#2b91af;">Dictionary</span>&lt;<span style="color:blue;">string</span>, <span style="color:blue;">string</span>&gt; tokens = <span style="color:blue;">new</span> <span style="color:#2b91af;">Dictionary</span>&lt;<span style="color:blue;">string</span>, <span style="color:blue;">string</span>&gt;();
<p style="margin:0;padding:0;">&nbsp;
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:blue;">string</span> clientId = <span style="color:#a31515;">"117342178314989"</span>;
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:blue;">string</span> redirectUrl = <span style="color:#a31515;">"http://localhost/Facebook/oauth/oauth-redirect.aspx"</span>;
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:blue;">string</span> clientSecret = <span style="color:#a31515;">"bc7996cfc4f0c66d0417b54eea73f4e7"</span>;
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:blue;">string</span> scope = <span style="color:#a31515;">"read_friendlists,user_status"</span>;
<p style="margin:0;padding:0;">&nbsp;
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:blue;">string</span> url = <span style="color:blue;">string</span>.Format(<span style="color:#a31515;">"https://graph.facebook.com/oauth/access_token?client_id={0}&amp;redirect_uri={1}&amp;client_secret={2}&amp;code={3}&amp;scope={4}"</span>,
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; clientId, redirectUrl, clientSecret, code, scope);
<p style="margin:0;padding:0;">&nbsp;
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:#2b91af;">HttpWebRequest</span> request = <span style="color:#2b91af;">WebRequest</span>.Create(url) <span style="color:blue;">as</span> <span style="color:#2b91af;">HttpWebRequest</span>;
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:blue;">using</span> (<span style="color:#2b91af;">HttpWebResponse</span> response = request.GetResponse() <span style="color:blue;">as</span> <span style="color:#2b91af;">HttpWebResponse</span>)
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:#2b91af;">StreamReader</span> reader = <span style="color:blue;">new</span> <span style="color:#2b91af;">StreamReader</span>(response.GetResponseStream());
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:blue;">string</span> retVal = reader.ReadToEnd();
<p style="margin:0;padding:0;">&nbsp;
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:blue;">foreach</span> (<span style="color:blue;">string</span> token <span style="color:blue;">in</span> retVal.Split(<span style="color:#a31515;">'&amp;'</span>))
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; tokens.Add(token.Substring(0, token.IndexOf(<span style="color:#a31515;">"="</span>)),
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; token.Substring(token.IndexOf(<span style="color:#a31515;">"="</span>) + 1, token.Length - token.IndexOf(<span style="color:#a31515;">"="</span>) - 1));
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }
<p style="margin:0;padding:0;">&nbsp;
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:blue;">return</span> tokens;
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }
<p style="margin:0;padding:0;">&nbsp;&nbsp;&nbsp; }
<p style="margin:0;padding:0;">}
</div>
</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/multitiered.wordpress.com/216/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/multitiered.wordpress.com/216/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/multitiered.wordpress.com/216/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/multitiered.wordpress.com/216/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/multitiered.wordpress.com/216/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/multitiered.wordpress.com/216/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/multitiered.wordpress.com/216/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/multitiered.wordpress.com/216/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/multitiered.wordpress.com/216/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/multitiered.wordpress.com/216/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/multitiered.wordpress.com/216/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/multitiered.wordpress.com/216/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/multitiered.wordpress.com/216/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/multitiered.wordpress.com/216/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=multitiered.wordpress.com&amp;blog=14707195&amp;post=216&amp;subd=multitiered&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://multitiered.wordpress.com/2010/08/05/getting-started-with-the-facebook-c-sharp-sdk/feed/</wfw:commentRss>
		<slash:comments>40</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/eb46b0549be16729844d43f494e0f45d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">udpeters</media:title>
		</media:content>

		<media:content url="http://multitiered.files.wordpress.com/2010/08/create-facebook-application.jpg" medium="image">
			<media:title type="html">create facebook application</media:title>
		</media:content>

		<media:content url="http://multitiered.files.wordpress.com/2010/08/my-application-overview.jpg" medium="image">
			<media:title type="html">my application overview</media:title>
		</media:content>

		<media:content url="http://multitiered.files.wordpress.com/2010/08/watch-me.jpg" medium="image">
			<media:title type="html">watch me</media:title>
		</media:content>

		<media:content url="http://multitiered.files.wordpress.com/2010/08/watch-me-friends.jpg" medium="image">
			<media:title type="html">watch me friends</media:title>
		</media:content>
	</item>
		<item>
		<title>Integrating Selenium Tests into CruiseControl.Net via NUnit</title>
		<link>http://multitiered.wordpress.com/2010/07/25/integrating-selenium-tests-into-cruisecontrol-net-via-nunit/</link>
		<comments>http://multitiered.wordpress.com/2010/07/25/integrating-selenium-tests-into-cruisecontrol-net-via-nunit/#comments</comments>
		<pubDate>Mon, 26 Jul 2010 02:10:25 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Continuous Integration]]></category>
		<category><![CDATA[CruiseControl.Net]]></category>
		<category><![CDATA[NUnit]]></category>
		<category><![CDATA[Selenium]]></category>

		<guid isPermaLink="false">http://multitiered.wordpress.com/?p=192</guid>
		<description><![CDATA[Getting Selenium and CruiseControl.Net to talk to each other requires some work and behind-the-scenes configuration. Before incorporating Selenium tests into CruiseControl.Net, make sure you: Understand the basics of CruiseControl.Net and how to configure it Review Selenium&#8217;s Web Application Testing System and setup your first example test To successfully get Selenium, NUnit and CruiseControl.Net talking to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=multitiered.wordpress.com&amp;blog=14707195&amp;post=192&amp;subd=multitiered&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Getting Selenium and CruiseControl.Net to talk to each other requires some work and behind-the-scenes configuration. Before incorporating Selenium tests into CruiseControl.Net, make sure you:</p>
<ul>
<li><a href="http://multitiered.wordpress.com/2010/07/23/configuring-cruisecontrol-net-svn-visual-studio-2008-and-msbuild/" target="_blank">Understand the basics of CruiseControl.Net and how to configure it</a></li>
<li><a href="http://multitiered.wordpress.com/2010/07/18/creating-selenium-unit-test-suites-with-nunit/" target="_blank">Review Selenium&#8217;s Web Application Testing System and setup your first example test</a></li>
</ul>
<p>To successfully get Selenium, NUnit and CruiseControl.Net talking to each other, you will have to accomplish the following:</p>
<ol>
<li>Configure Selenium RC to run as a service</li>
<li>Edit your CruiseControl.Net config file to include a NUnit task</li>
<li>Point NUnit to your Selenium Unit Test Library</li>
</ol>
<p>The details of this article help to get you started in accomplishing the tasks above. </p>
<h3>Running Selenium RC as a service</h3>
<p>By default, Selenium RC runs as a stand-alone application capable of managing Selenium unit tests and directing traffic for different browser requests. If you want to incorporate your Selenium tests into CruiseControl.Net, you have to get Selenium RC running as a service.</p>
<p>I found <a href="http://unintelligible.org/blog/2009/07/28/installing-selenium-rc-as-a-windows-service/" target="_blank">a great resource</a> that details how to do this. To summarize the article, follow these simple steps:</p>
<ol>
<li>Download a copy of the <a href="http://www.microsoft.com/downloads/details.aspx?familyid=9d467a69-57ff-4ae7-96ee-b18c4790cffd&amp;displaylang=en" target="_blank">Windows Resource Kit</a>.</li>
<li>
Register the new service &#8220;SeleniumRC&#8221;<br />
</p>
<pre>
"C:\Program Files\Windows Resource Kits\Tools\instsrv.exe" SeleniumRC
"C:\Program Files\Windows Resource Kits\Tools\srvany.exe" -a [myuser] -p [mypass]
</pre>
</li>
<li>
Edit your registry to include the path of your Selenium RC installation and executable:<br />
</p>
<pre>
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SeleniumRC\Parameters]
"Application"="java.exe"
"AppDirectory"="C:\\Program Files\\selenium-server-1.0.1"
"AppParameters"="-Xrs -jar selenium-server.jar"
</pre>
</li>
<p>
Now that you have the Selenium RC service created, go to <strong>Administrative Tools &gt; Services</strong> and start the service. Check the system event logs for errors to ensure everything is working properly.
</p>
<h3>Wire-Up Selenium to CruiseControl.Net using NUnit</h3>
<p>With the Selenium RC service running, edit your CruseControl.Net config file to incorporate NUnit:</p>
<pre>
<div style="font-family:Courier New;font-size:8pt;color:black;background:none repeat scroll 0 0;margin:0;padding:0;">
<p style="margin:0;padding:0;"><span style="color:blue;">&nbsp; &nbsp; &lt;</span><span style="color:#a31515;">tasks</span><span style="color:blue;">&gt;</span>
<p style="margin:0;padding:0;"><span style="color:blue;">&nbsp; &nbsp; &nbsp; &lt;</span><span style="color:#a31515;">exec</span><span style="color:blue;">&gt;</span>
<p style="margin:0;padding:0;"><span style="color:blue;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;</span><span style="color:#a31515;">executable</span><span style="color:blue;">&gt;</span>C:\Program Files (x86)\NUnit 2.5.5\bin\net-2.0\nunit-console.exe<span style="color:blue;">&lt;/</span><span style="color:#a31515;">executable</span><span style="color:blue;">&gt;</span>
<p style="margin:0;padding:0;"><span style="color:blue;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;</span><span style="color:#a31515;">buildArgs</span><span style="color:blue;">&gt;</span>"C:\Users\Dave\Documents\Visual Studio 2008\Projects\SeleniumTest\SeleniumTest\bin\Debug\SeleniumTest.dll"<span style="color:blue;">&lt;/</span><span style="color:#a31515;">buildArgs</span><span style="color:blue;">&gt;</span>
<p style="margin:0;padding:0;"><span style="color:blue;">&nbsp; &nbsp; &nbsp; &lt;/</span><span style="color:#a31515;">exec</span><span style="color:blue;">&gt;</span>
<p style="margin:0;padding:0;"><span style="color:blue;">&nbsp; &nbsp; &lt;/</span><span style="color:#a31515;">tasks</span><span style="color:blue;">&gt;</span>
</div>
</pre>
</pre>
<p>After a successful execution of your test plan using Selenium RC in CruiseControl.Net, you should see a response from NUnit in your CruiseControl.Net build log like the following:</p>
<pre>
&lt;buildresults&gt;
  &lt;message&gt;NUnit version 2.5.5.10112&lt;/message&gt;
  &lt;message&gt;Copyright (C) 2002-2009 Charlie Poole.&lt;/message&gt;
  &lt;message&gt;Copyright (C) 2002-2004 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov.&lt;/message&gt;
  &lt;message&gt;Copyright (C) 2000-2002 Philip Craig.&lt;/message&gt;
  &lt;message&gt;All Rights Reserved.&lt;/message&gt;
  &lt;message&gt;Runtime Environment - &lt;/message&gt;
  &lt;message&gt;   OS Version: Microsoft Windows NT 6.1.7600.0&lt;/message&gt;
  &lt;message&gt;  CLR Version: 2.0.50727.4927 ( Net 2.0 )&lt;/message&gt;
  &lt;message&gt;ProcessModel: Default    DomainUsage: Single&lt;/message&gt;
  &lt;message&gt;Execution Runtime: net-2.0&lt;/message&gt;
  &lt;message&gt;.&lt;/message&gt;
  &lt;message&gt;Tests run: 1, Errors: 0, Failures: 0, Inconclusive: 0, Time: 20.9481982 seconds&lt;/message&gt;
  &lt;message&gt;  Not run: 0, Invalid: 0, Ignored: 0, Skipped: 0&lt;/message&gt;
&lt;/buildresults&gt;
&lt;/build&gt;
&lt;/cruisecontrol&gt;
</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/multitiered.wordpress.com/192/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/multitiered.wordpress.com/192/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/multitiered.wordpress.com/192/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/multitiered.wordpress.com/192/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/multitiered.wordpress.com/192/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/multitiered.wordpress.com/192/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/multitiered.wordpress.com/192/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/multitiered.wordpress.com/192/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/multitiered.wordpress.com/192/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/multitiered.wordpress.com/192/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/multitiered.wordpress.com/192/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/multitiered.wordpress.com/192/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/multitiered.wordpress.com/192/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/multitiered.wordpress.com/192/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=multitiered.wordpress.com&amp;blog=14707195&amp;post=192&amp;subd=multitiered&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://multitiered.wordpress.com/2010/07/25/integrating-selenium-tests-into-cruisecontrol-net-via-nunit/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/eb46b0549be16729844d43f494e0f45d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">udpeters</media:title>
		</media:content>
	</item>
	</channel>
</rss>
