<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://weblogs.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Shawn's Technical Blog</title><link>http://weblogs.asp.net/smehaffie/default.aspx</link><description /><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Surface Tablets: The Price Must Be Right</title><link>http://weblogs.asp.net/smehaffie/archive/2012/10/03/surface-tablets-the-price-must-be-right.aspx</link><pubDate>Thu, 04 Oct 2012 04:49:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:9041607</guid><dc:creator>smehaffie</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/smehaffie/rsscomments.aspx?PostID=9041607</wfw:commentRss><comments>http://weblogs.asp.net/smehaffie/archive/2012/10/03/surface-tablets-the-price-must-be-right.aspx#comments</comments><description>&lt;p&gt;After watching the video of the announcement about the new Surface tablets and comments by other users I wanted to add my thoughts to the discussion.&amp;nbsp; Balmer stated that sales of the surface tables will only be a small percentage of tablet sales.&amp;nbsp; I personally think that how the Surface tablets sell will be a big indicator on how successful Win8 is going to be on tablets (Unless MS overprices it).&amp;nbsp; This is similar to how people will look at Nokia WP8 phone sales as an indicator on how successful WP8 will be.&lt;/p&gt;  &lt;h1&gt;Partners / Pricing&lt;/h1&gt;  &lt;p&gt;Microsoft has set the bar for it’s hardware partners for what users should expect from a Win8 based tablet. I do realize MS has a very fine line they have to walk to keep hardware partners happy. On the other hand if they overprice both Surface models they will not sell many and the Surface tablets will be seen as a big failure.&amp;nbsp; &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Surface:&lt;/strong&gt;&amp;nbsp; This is the ARM based tablet.&amp;nbsp; There is speculation that this will be priced similar to the iPad.&amp;nbsp; I think that this would be a mistake. In a lot of ways this tablet is comparable to the iPad, but it lacks just enough features to not be able to be a compete against the iPad.&amp;nbsp; This does not have to be priced as low as a Kindle Fire, but it cannot be a high as an iPad either. Below are the negatives I see at this time&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;The main reason is that there will not be a lot of WinRT applications for the device when it is launched. &lt;/li&gt;    &lt;li&gt;No Retina display.&amp;nbsp; Although it does have HD display it is not close to the Retina display. &lt;/li&gt;    &lt;li&gt;Most developers are waiting to write applications to see how the new Win8 tablets sell, since time is limited and no one wants to spend time writing applications for a limited customer base. &lt;/li&gt;    &lt;li&gt;Not having the Stylus and Palm block on this devise.&amp;nbsp; If the hardware will support it, MS needs to try to get this feature on both by launch. There are many business users who would use this feature to take notes in meetings, write documents, etc. These business user shouldn’t have to buy Pro version for this feature. &lt;/li&gt;    &lt;li&gt;The rumor that the ARM version will not be able to connect to a domain. If true, this would be bad be bad because IMO a majority of business users do not need the Pro version to check emails, write/read office documents, take notes, calendar, contacts, blogging, browsing internet, etc. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;strong&gt;Surface Pro:&lt;/strong&gt; This is the Intel-based tablet.&amp;nbsp; This looks really nice, but pricing based on the Ultrabooks&amp;nbsp; would be a mistake because at this time Ultrabooks range from $800 – $1,400.&amp;nbsp; These are not ultra-books, these are tablets (no 500GB+ HD, No DVD, etc.), so they would be overprices if MS uses ultra-books as the basis for pricing.&amp;nbsp; IMO the 64GB version could be priced similar to the iPad 3, and MS could justify a little higher price for the 128GB version.&amp;nbsp; If they had a 256GB and/or 512GB version then they might justify the price approaching high end ultra-book prices. The fact that these tablets will run all Win7 applications eliminates the “lack of applications” argument, thus another reason it is good iPad competitor.&lt;/p&gt;  &lt;p mce_keep="true"&gt;&amp;nbsp;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Price Comparison&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;   &lt;table width="594" border="1" cellspacing="0" cellpadding="2"&gt;&lt;tbody&gt;       &lt;tr&gt;         &lt;td width="59" valign="top"&gt;&amp;nbsp;&lt;/td&gt;          &lt;td width="48" valign="top"&gt;&lt;strong&gt;16GB&lt;/strong&gt;&lt;/td&gt;          &lt;td width="48" valign="top"&gt;&lt;strong&gt;32GB&lt;/strong&gt;&lt;/td&gt;          &lt;td width="48" valign="top"&gt;&lt;strong&gt;64GB&lt;/strong&gt;&lt;/td&gt;          &lt;td width="55" valign="top"&gt;&lt;strong&gt;128GB&lt;/strong&gt;&lt;/td&gt;          &lt;td width="69" valign="top"&gt;&lt;strong&gt;Extra Memory              &lt;br&gt;&lt;/strong&gt;&lt;/td&gt;          &lt;td width="75" valign="top"&gt;&lt;strong&gt;Display&lt;/strong&gt;&lt;/td&gt;          &lt;td width="75" valign="top"&gt;&lt;strong&gt;Chip&lt;/strong&gt;&lt;/td&gt;          &lt;td width="41" valign="top"&gt;&lt;strong&gt;USB&lt;/strong&gt;&lt;/td&gt;          &lt;td width="64" valign="top"&gt;&lt;strong&gt;Camera&lt;/strong&gt;&lt;/td&gt;          &lt;td width="10" valign="top"&gt;&lt;strong&gt;Battery Life&lt;/strong&gt;&lt;/td&gt;       &lt;/tr&gt;        &lt;tr&gt;         &lt;td width="59" valign="top"&gt;iPad&lt;/td&gt;          &lt;td width="48" valign="top"&gt;$499&lt;/td&gt;          &lt;td width="48" valign="top"&gt;$599&lt;/td&gt;          &lt;td width="48" valign="top"&gt;$699&lt;/td&gt;          &lt;td width="55" valign="top"&gt;N/A&lt;/td&gt;          &lt;td width="70" valign="top"&gt;No&lt;/td&gt;          &lt;td width="76" valign="top"&gt;9.7in, Retina,            &lt;br&gt;2048x1536&lt;/td&gt;          &lt;td width="75" valign="top"&gt;Dual-Core a5X&lt;/td&gt;          &lt;td width="41" valign="top"&gt;No&lt;/td&gt;          &lt;td width="63" valign="top"&gt;5MP -RF&lt;/td&gt;          &lt;td width="10" valign="top"&gt;9-10 hours&lt;/td&gt;       &lt;/tr&gt;        &lt;tr&gt;         &lt;td width="59" valign="top"&gt;Nexus 7&lt;/td&gt;          &lt;td width="48" valign="top"&gt;$249&lt;/td&gt;          &lt;td width="48" valign="top"&gt;N/A&lt;/td&gt;          &lt;td width="48" valign="top"&gt;N/A&lt;/td&gt;          &lt;td width="55" valign="top"&gt;N/A&lt;/td&gt;          &lt;td width="70" valign="top"&gt;Yes,            &lt;br&gt;MicroSD&lt;/td&gt;          &lt;td width="76" valign="top"&gt;7in,            &lt;br&gt;HD,             &lt;br&gt;1280X800&lt;/td&gt;          &lt;td width="74" valign="top"&gt;Quad Core Tegra 3&lt;/td&gt;          &lt;td width="41" valign="top"&gt;Yes&lt;/td&gt;          &lt;td width="63" valign="top"&gt;1.2GB-FF            &lt;br&gt;&lt;/td&gt;          &lt;td width="10" valign="top"&gt;9-10 hours, 300 stand-by&lt;/td&gt;       &lt;/tr&gt;        &lt;tr&gt;         &lt;td width="59" valign="top"&gt;Galaxy Tab2, 10'’&lt;/td&gt;          &lt;td width="48" valign="top"&gt;$399&lt;/td&gt;          &lt;td width="48" valign="top"&gt;N/A&lt;/td&gt;          &lt;td width="48" valign="top"&gt;N/A&lt;/td&gt;          &lt;td width="55" valign="top"&gt;N/A&lt;/td&gt;          &lt;td width="70" valign="top"&gt;Yes            &lt;br&gt;32GB&lt;/td&gt;          &lt;td width="76" valign="top"&gt;TFT(PLS)            &lt;br&gt;1280x800&lt;/td&gt;          &lt;td width="74" valign="top"&gt;Dual Processor&lt;/td&gt;          &lt;td width="41" valign="top"&gt;Yes&lt;/td&gt;          &lt;td width="63" valign="top"&gt;VGA-FF            &lt;br&gt;3MP-RF&lt;/td&gt;          &lt;td width="10" valign="top"&gt;8hrs&lt;/td&gt;       &lt;/tr&gt;        &lt;tr&gt;         &lt;td width="59" valign="top"&gt;Surface RT&lt;/td&gt;          &lt;td width="48" valign="top"&gt;N/A&lt;/td&gt;          &lt;td width="48" valign="top"&gt;???&lt;/td&gt;          &lt;td width="48" valign="top"&gt;???&lt;/td&gt;          &lt;td width="55" valign="top"&gt;N/A&lt;/td&gt;          &lt;td width="70" valign="top"&gt;Yes            &lt;br&gt;MicroSD             &lt;br&gt;&lt;/td&gt;          &lt;td width="76" valign="top"&gt;10.6” ClearType HD Display&lt;/td&gt;          &lt;td width="74" valign="top"&gt;ARM&lt;/td&gt;          &lt;td width="41" valign="top"&gt;Yes,            &lt;br&gt;2.0&lt;/td&gt;          &lt;td width="63" valign="top"&gt;???&lt;/td&gt;          &lt;td width="10" valign="top"&gt;???&lt;/td&gt;       &lt;/tr&gt;        &lt;tr&gt;         &lt;td width="58" valign="top"&gt;Surface Pro&lt;/td&gt;          &lt;td width="47" valign="top"&gt;N/A&lt;/td&gt;          &lt;td width="47" valign="top"&gt;N/A&lt;/td&gt;          &lt;td width="47" valign="top"&gt;???&lt;/td&gt;          &lt;td width="54" valign="top"&gt;???&lt;/td&gt;          &lt;td width="70" valign="top"&gt;Yes,            &lt;br&gt;microSDX&lt;/td&gt;          &lt;td width="76" valign="top"&gt;10.6” ClearType Full HD Display&lt;/td&gt;          &lt;td width="74" valign="top"&gt;Intel&lt;/td&gt;          &lt;td width="41" valign="top"&gt;Yes,            &lt;br&gt;3.0&lt;/td&gt;          &lt;td width="63" valign="top"&gt;???&lt;/td&gt;          &lt;td width="10" valign="top"&gt;???&lt;/td&gt;       &lt;/tr&gt;     &lt;/tbody&gt;&lt;/table&gt; &lt;/p&gt;  &lt;p mce_keep="true"&gt;&amp;nbsp;&lt;/p&gt;  &lt;p&gt;So here is what I think the pricing should be for Surface to be successful (based on the table above)&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Surface 32GB: $300-$350 (Galaxy) &lt;/li&gt;    &lt;li&gt;Surface 64GB: $400-$450 (low end iPad) &lt;/li&gt;    &lt;li&gt;Surface Pro 64GB: $500-$600 (high end iPad) &lt;/li&gt;    &lt;li&gt;Surface Pro 128GB: $600-$750 (i5 laptop)      &lt;br&gt;      &lt;br&gt;-------------------------------------------------------------------------------------------------------------------------------------------- &lt;/li&gt;    &lt;li&gt;Surface Pro 256GB: $800-$900 (low end ultra-book) – Sadly, this option does not exist for Surface Pro version. &lt;/li&gt;    &lt;li&gt;Surface Pro 512GB: $900-$1,000 (high end ultra-book) – Sadly, this option does not exist for Surface Pro version &lt;/li&gt; &lt;/ul&gt;  &lt;h1&gt;&lt;u&gt;Conclusion&lt;/u&gt;&lt;/h1&gt;  &lt;p&gt;I personally am very excited about the surface tablets and planning on getting one.&amp;nbsp; But if MS is to worried about appeasing OEM’s they could price themselves out of the market before they even have a chance.&amp;nbsp; I for one am hoping MS prices these to sell a lot of them, and there is a huge advertising push to sell both versions of the tablet. Otherwise a year from now the Surface could be seen as another MS failure to gain any traction in the tablet market.&amp;nbsp; I’m not saying MS has to get ahead of either Apple/Android, but they do need to get a respectable share of the market (15%+) pretty quick and the Surface tablets should lead the way and set the standard for all tablet makers. If overpriced the Surface tablets could be on the same list as MS Bob and Kin as epic failures.&amp;nbsp; &lt;/p&gt;  &lt;p&gt;If overpriced there will be no incentive to buy the Surface tablets, and a better option would be to get an iPad, jailbreak it and then install Win8&amp;nbsp; on it. According to my cousin who is an Apple fan boy, “Win8 on tablets kicks Apples butt and is so much better than iOS”.&amp;nbsp; My interpretation is “Win8 makes the iPad better (great hardware with even better OS)”. MS and OEM’s take note, we need quality Win8 tablets&amp;nbsp; at a reasonable price.&amp;nbsp; Remember price it right and we could see 1-2 million sell the first couple of months as opposed to selling 1-2 million all year.&amp;nbsp; Sometimes profits come from selling large quantities and making smaller profits per device, instead of selling a smaller number of devices at a higher profit.&amp;nbsp; For all tablets (surface and OEM devices) selling a large quantity is important because without millions of devices out there, developers will have no incentive to spend time writing application for Win8 based tablets. &lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=9041607" width="1" height="1"&gt;</description></item><item><title>MS Expression Web 4 SuperPreview – Big Disappointment</title><link>http://weblogs.asp.net/smehaffie/archive/2010/06/13/ms-expression-web-4-superpreview-big-disappointment.aspx</link><pubDate>Mon, 14 Jun 2010 02:48:59 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7529121</guid><dc:creator>smehaffie</dc:creator><slash:comments>14</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/smehaffie/rsscomments.aspx?PostID=7529121</wfw:commentRss><comments>http://weblogs.asp.net/smehaffie/archive/2010/06/13/ms-expression-web-4-superpreview-big-disappointment.aspx#comments</comments><description>&lt;p&gt;I just downloaded Expression 4 and expected to see some improvements in the Web4 SuperPreview application.&amp;#160; The one main function I was expecting to be in this release is the ability to enter data and click on links so pages of the sites could be assessed.&amp;#160; There a many use cases where this functionality is needed and there were quite a few people vocal about it when MS first released the application. &lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;hr /&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;1) Where you have to login to a site to access either all the content or some of the content on the site&lt;/p&gt;  &lt;p&gt;2) Where you have to enter date in a certain order and cannot go to next page until the previous pages data is filled out (payment process, storefront, etc).&lt;/p&gt;  &lt;p&gt;3) Where you just want to make sure things are displayed correctly based on data entered (validation messages, etc).&lt;/p&gt;  &lt;p&gt;4 ) You need to make sure the links go to the page in all the different browsers.&amp;#160; I have seen scenerios where links worked fine in all but one browser, or for some reason the text showed on screen but it was not a clickable link.&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;hr /&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;IMO this application is a great idea, but until MS fixed the above issue and add the functionality above the SuperPreview is totally worthless unless you need it to test a totally static site that does not require any user input at all to get access to the content.&amp;#160; There is no reason this feature should not have been in this release, and it should have been a priority to make sure it was.&lt;/p&gt;  &lt;p&gt;Let me know how you feel about the new version of the Web4 SuperPreview application.&amp;#160; Did MS really miss the target on this by not adding this functionality, or do I think it is a bigger deal that it really is?&amp;#160; If you are actively using SuperPreview, please post how you are using it and the type of sites you are using it on.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7529121" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/smehaffie/archive/tags/General+Software+Development/default.aspx">General Software Development</category><category domain="http://weblogs.asp.net/smehaffie/archive/tags/MS+Expression/default.aspx">MS Expression</category></item><item><title>MS Ajax Libraries and Configured Assemblies</title><link>http://weblogs.asp.net/smehaffie/archive/2010/04/19/ms-ajax-libraries-and-configured-assemblies.aspx</link><pubDate>Mon, 19 Apr 2010 20:02:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7449687</guid><dc:creator>smehaffie</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/smehaffie/rsscomments.aspx?PostID=7449687</wfw:commentRss><comments>http://weblogs.asp.net/smehaffie/archive/2010/04/19/ms-ajax-libraries-and-configured-assemblies.aspx#comments</comments><description>&lt;p&gt;&lt;b&gt;&lt;font size="4"&gt;&lt;u&gt;Use Case&lt;/u&gt;&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;You have a brand new IIS servers that has .Net 3.5 installed and are migrating sites to the new servers.&amp;nbsp; In the process of migrating sites you come across some sites that get an error about the version of AJAX libraries being references in the web.config.&amp;nbsp; In the web.config all the entries reference 1.0.61025.0, but the older version of the AJAX libraries are not installed on the new servers, only the latest version is installed that comes with .Net 3.5.&amp;nbsp; So what are the options to fix this issue.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;font size="4"&gt;&lt;u&gt;Solutions&lt;/u&gt;&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;1) Install the older version of the AJAX Libraries: Although this works, IMO it is never a great idea to install an older version of a library after a newer version has been installed.&amp;nbsp; Plus, if all new application use the latest versions, is it worth the effort of installing the older version for a few legacy applications?&lt;/p&gt;  &lt;p&gt;2) Update the web.config files so all references use latest version (3.5.0.0):&amp;nbsp; This option is very time consuming and error prone. In addition, you will also have to update any pages where there is a register tag for the older libraries as well.&amp;nbsp; This would require you to redeploy any application that have this issue.&lt;/p&gt;  &lt;p&gt;3) Use the Configured Assembly capabilities of .Net (aka: Assembly Bindings) to make any application that uses the older AJAX libraries to use the new AJAX libraries.&amp;nbsp; IMO, this is the easiest, quickest and least invasive way to fix the issue.&amp;nbsp; Below are the steps to implement this fix.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;u&gt;&lt;font size="4"&gt;Solution #3&lt;/font&gt;&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;Do the following steps on the IIS servers that the issue is occurring.&amp;nbsp; The 2 assemblies that need assemblies bindings created are: System.Web.Extension &amp;amp; System.Web.Extensions.Design &lt;/p&gt;  &lt;p&gt;1) Go to Start - &amp;gt; All Program -&amp;gt; Administrative Tools -&amp;gt; Microsoft .NET Framework 2.0 Configuration.    &lt;br&gt;2) Right click on "Configured Assemblies" to view list of configured assemblies.     &lt;br&gt;3) Left Click on right pane to bring up menu and choose "Add".     &lt;br&gt;4) Make sure "Choose and assembly from the assembly cache is checked" and click the "Choose Assembly" button.     &lt;br&gt;5) Choose System.Web.Extension (does not matter what version).     &lt;br&gt;6) Click the "Finish" button.     &lt;br&gt;7) Binding Policy Tab     &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; - Enter Requested Version = 1.0.61025.0     &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; - Enter New Version = 3.5.0.0     &lt;br&gt;8) Repeat steps 2-7 for the System.Web.Extensions.Design assembly.&lt;/p&gt;  &lt;p&gt;---------------------------------------------------------------------------------------------------------------------------------------------------------&lt;/p&gt;  &lt;p&gt;Note: If "Microsoft .NET Framework 2.0 Configuration does not exist under Admin tools use mmc to access it (see below)&lt;/p&gt;  &lt;p&gt;1) Start -&amp;gt; Run -&amp;gt; Enter MMC    &lt;br&gt;2) File - &amp;gt; Add/Remove Snap-In then Click "Add" button     &lt;br&gt;3) Choose ".Net 2.0 Configuration" then click "Add" button and then the "Close" Button.     &lt;br&gt;4) On "Add/Remove Snapin" windows click the "OK" Button.     &lt;br&gt;5) Expand the tree on the right and you can start following the directions above for adding the configured assemblies. &lt;/p&gt;  &lt;p&gt;---------------------------------------------------------------------------------------------------------------------------------------------------------&lt;/p&gt;&lt;p&gt;&lt;div&gt;
&lt;script type="text/javascript"&gt;
var addthis_pub="smehaffie";
var addthis_options="email, print, digg, slashdot, delicious, twitter, live, myspace, facebook, google, stumbleupon, newsvine";
&lt;/script&gt;

&lt;a href="http://www.addthis.com/bookmark.php?v=20" onmouseover="return addthis_open(this, '', '[URL]', '[TITLE]')" onmouseout="addthis_close()" onclick="return addthis_sendto()"&gt;
&lt;img src="http://s7.addthis.com/static/btn/lg-share-en.gif" alt="Share This Post" style="border:0"/&gt;
&lt;/a&gt;

&lt;/div&gt; &lt;br&gt;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7449687" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/smehaffie/archive/tags/General+Software+Development/default.aspx">General Software Development</category><category domain="http://weblogs.asp.net/smehaffie/archive/tags/AJAX/default.aspx">AJAX</category><category domain="http://weblogs.asp.net/smehaffie/archive/tags/ASP.Net/default.aspx">ASP.Net</category></item><item><title>Worthless Anti-Spam (What can we learn)</title><link>http://weblogs.asp.net/smehaffie/archive/2010/04/18/worthless-anti-spam-what-can-we-learn.aspx</link><pubDate>Sun, 18 Apr 2010 05:10:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7448622</guid><dc:creator>smehaffie</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/smehaffie/rsscomments.aspx?PostID=7448622</wfw:commentRss><comments>http://weblogs.asp.net/smehaffie/archive/2010/04/18/worthless-anti-spam-what-can-we-learn.aspx#comments</comments><description>&lt;p&gt;I recently can across a site that had a “anti-spam” field at the bottom of the entry from.&amp;nbsp; The first issue I had with it was that at 1280X800 you could not read the value you were suppose to enter (see below).&amp;nbsp; You tell me, should you enter div, dlv, piv, or plv. &lt;/p&gt;  &lt;p&gt;   &lt;br&gt;&lt;a href="http://weblogs.asp.net/blogs/smehaffie/AnitSpamField_79593C77.png" mce_href="http://weblogs.asp.net/blogs/smehaffie/AnitSpamField_79593C77.png"&gt;&lt;img src="http://weblogs.asp.net/blogs/smehaffie/AnitSpamField_thumb_5B0E8581.png" style="border-width: 0px; display: inline;" title="AnitSpamField" alt="AnitSpamField" mce_src="http://weblogs.asp.net/blogs/smehaffie/AnitSpamField_thumb_5B0E8581.png" border="0" height="28" width="244"&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;But even worse than not being readable at high resolutions is the fact that the programmer who coded it really did not understand what this was used for.&amp;nbsp; An anti-spam (aka: catpcha) entry field should not be able to be read by looking at the HTML DOM object (so entry of value cannot be scripted).&amp;nbsp; In this case the value is simply a disabled text input filed that has the value you need to type.&amp;nbsp; So a hacker would simply need to search for text input field named “spam2” and then they could flood the site with spam.&lt;/p&gt;  &lt;div style="border: 1px solid silver; margin: 20px 0px 10px; padding: 4px; overflow: auto; text-align: left; line-height: 12pt; background-color: rgb(244, 244, 244); width: 97.5%; font-family: 'Courier New',courier,monospace; direction: ltr; max-height: 200px; font-size: 8pt; cursor: text;" id="codeSnippetWrapper"&gt;   &lt;div style="border-style: none; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;" id="codeSnippet"&gt;     &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);" id="lnum1"&gt;   1:&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;td&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);" id="lnum2"&gt;   2:&lt;/span&gt;   &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;label&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);" id="lnum3"&gt;   3:&lt;/span&gt;     &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;input&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;name&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="spam1"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;type&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="text"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;class&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="small"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;id&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="spam1"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;size&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="6"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;maxlength&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="3"&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);" id="lnum4"&gt;   4:&lt;/span&gt;     &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;input&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;name&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="spam2"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;type&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="text"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;class&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="small"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;id&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="spam2"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;value&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="plv"&lt;/span&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);" id="lnum5"&gt;   5:&lt;/span&gt;        &lt;span style="color: rgb(255, 0, 0);"&gt;disabled&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="disabled"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;size&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="6"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;maxlength&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="3"&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);" id="lnum6"&gt;   6:&lt;/span&gt;     * &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;span&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;class&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="small"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;- Anti-SPAM key - please enter matching value&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;span&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);" id="lnum7"&gt;   7:&lt;/span&gt;   &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;label&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);" id="lnum8"&gt;   8:&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;td&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;

&lt;p&gt;There are some things to learn from this example:&lt;/p&gt;

&lt;p&gt;1) Always make sure you understand why you are coding a feature/function for any program you write.&amp;nbsp; Just following the requirements without realizing the “why” will sooner or later come back to bite you.&amp;nbsp; I think the above example appears to be an example of this.&lt;/p&gt;

&lt;p&gt;2) Always check how the screen appears in different resolutions.&amp;nbsp; In this case it was pretty much unreadable in 1280x800, but you could read it in 800X600 (but most people I know do not have their resolution set that low).&amp;nbsp; Lucky for me I could “View Source” and get the value I needed to enter.&lt;/p&gt;&lt;p&gt;&lt;div&gt;
&lt;script type="text/javascript"&gt;
var addthis_pub="smehaffie";
var addthis_options="email, print, digg, slashdot, delicious, twitter, live, myspace, facebook, google, stumbleupon, newsvine";
&lt;/script&gt;

&lt;a href="http://www.addthis.com/bookmark.php?v=20" onmouseover="return addthis_open(this, '', '[URL]', '[TITLE]')" onmouseout="addthis_close()" onclick="return addthis_sendto()"&gt;
&lt;img src="http://s7.addthis.com/static/btn/lg-share-en.gif" alt="Share This Post" style="border:0"/&gt;
&lt;/a&gt;

&lt;/div&gt; &lt;br&gt;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7448622" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/smehaffie/archive/tags/General+Software+Development/default.aspx">General Software Development</category></item><item><title>Calling Web Services That Use Self-Signed Certificates</title><link>http://weblogs.asp.net/smehaffie/archive/2009/09/10/calling-web-services-that-use-self-signed-certificates.aspx</link><pubDate>Thu, 10 Sep 2009 23:00:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7199748</guid><dc:creator>smehaffie</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/smehaffie/rsscomments.aspx?PostID=7199748</wfw:commentRss><comments>http://weblogs.asp.net/smehaffie/archive/2009/09/10/calling-web-services-that-use-self-signed-certificates.aspx#comments</comments><description>&lt;p&gt;When you try to call a web service that uses a self-signed certificate from a client application you get the following error:    &lt;br&gt;&lt;font color="#ff0000"&gt;The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;This make sense since if you access the site directly in your browser you get an invalid certificate message.&amp;nbsp; When you look at the details of the error it states that the certificate cannot be verified up to a trusted certification authority.&amp;nbsp; This is not a big issue when using the browser since you can accept the certificate, and even add install the certificate so you don’t get the error on subsequent calls to the web services.&amp;nbsp; &lt;/p&gt;  &lt;p&gt;There are 2 ways you can fix this issue.&lt;/p&gt;  &lt;p&gt;1) You can install the certificate on all desktops/servers the client application is running on.&amp;nbsp; For a desktop application used by tons of people this is really not a good solution, and even for web application this still could become a maintenance/support nightmare.&amp;nbsp; &lt;/p&gt;  &lt;p&gt;2)&amp;nbsp; The other way is to add some code to your project that allows your application to ignore the certificate error.&amp;nbsp; Below are the instructions on how to do this in VS 2003 and VS2005/2008.&lt;/p&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;font size="4"&gt;&lt;u&gt;VS2003&lt;/u&gt;&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;1) Create a class files that contains the following code (I recommend calling the file Certificates.cs).&lt;/p&gt;  &lt;div style="background: rgb(227, 213, 193) none repeat scroll 0% 0%; font-family: envy code r vs; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: black; font-size: 10pt;"&gt;   &lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(64, 0, 128);"&gt;using&lt;/span&gt; &lt;span style="color: rgb(1, 0, 1);"&gt;System&lt;/span&gt;&lt;span style="color: rgb(46, 83, 209);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(1, 0, 1);"&gt;Net&lt;/span&gt;;&lt;/p&gt;    &lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(64, 0, 128);"&gt;using&lt;/span&gt; &lt;span style="color: rgb(1, 0, 1);"&gt;System&lt;/span&gt;&lt;span style="color: rgb(46, 83, 209);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(1, 0, 1);"&gt;Security&lt;/span&gt;&lt;span style="color: rgb(46, 83, 209);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(1, 0, 1);"&gt;Cryptography&lt;/span&gt;&lt;span style="color: rgb(46, 83, 209);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(1, 0, 1);"&gt;X509Certificates&lt;/span&gt;;&lt;/p&gt;    &lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&lt;/span&gt;&amp;nbsp;&lt;/p&gt;    &lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(166, 138, 74);"&gt;///&lt;/span&gt;&lt;span style="color: rgb(108, 73, 21); font-weight: bold;"&gt; &lt;/span&gt;&lt;span style="color: rgb(166, 138, 74);"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(166, 138, 74);"&gt;///&lt;/span&gt;&lt;span style="color: rgb(108, 73, 21); font-weight: bold;"&gt; Class to handle any certificate specific code&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 6&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(166, 138, 74);"&gt;///&lt;/span&gt;&lt;span style="color: rgb(108, 73, 21); font-weight: bold;"&gt; &lt;/span&gt;&lt;span style="color: rgb(166, 138, 74);"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 7&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(64, 0, 128);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(64, 0, 128);"&gt;class&lt;/span&gt; &lt;span style="color: rgb(1, 0, 1);"&gt;Certificates&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 8&lt;/span&gt; {&lt;/p&gt;    &lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 9&lt;/span&gt; }&lt;/p&gt;    &lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp; 10&lt;/span&gt;&amp;nbsp;&lt;/p&gt;    &lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp; 11&lt;/span&gt;&amp;nbsp;&lt;/p&gt;    &lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp; 12&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(166, 138, 74);"&gt;///&lt;/span&gt;&lt;span style="color: rgb(108, 73, 21); font-weight: bold;"&gt; &lt;/span&gt;&lt;span style="color: rgb(166, 138, 74);"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp; 13&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(166, 138, 74);"&gt;///&lt;/span&gt;&lt;span style="color: rgb(108, 73, 21); font-weight: bold;"&gt; Class to overide policy so calling a web service with a &lt;/span&gt;&lt;/p&gt;    &lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp; 14&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(166, 138, 74);"&gt;///&lt;/span&gt;&lt;span style="color: rgb(108, 73, 21); font-weight: bold;"&gt; self-signed cert works.&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp; 15&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(166, 138, 74);"&gt;///&lt;/span&gt;&lt;span style="color: rgb(108, 73, 21); font-weight: bold;"&gt; &lt;/span&gt;&lt;span style="color: rgb(166, 138, 74);"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp; 16&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(64, 0, 128);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(64, 0, 128);"&gt;class&lt;/span&gt; &lt;span style="color: rgb(1, 0, 1);"&gt;SelfSignedPolicy&lt;/span&gt; : &lt;span style="color: rgb(1, 0, 1);"&gt;ICertificatePolicy&lt;/span&gt; &lt;/p&gt;    &lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp; 17&lt;/span&gt; {&lt;/p&gt;    &lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp; 18&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: rgb(64, 0, 128);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(64, 0, 128);"&gt;bool&lt;/span&gt; &lt;span style="color: rgb(1, 0, 1);"&gt;CheckValidationResult&lt;/span&gt;(&lt;span style="color: rgb(1, 0, 1);"&gt;ServicePoint&lt;/span&gt; &lt;span style="color: rgb(1, 0, 1);"&gt;srvPoint&lt;/span&gt;, &lt;/p&gt;    &lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp; 19&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: rgb(1, 0, 1);"&gt;X509Certificate&lt;/span&gt; &lt;span style="color: rgb(1, 0, 1);"&gt;cert&lt;/span&gt;, &lt;/p&gt;    &lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp; 20&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: rgb(1, 0, 1);"&gt;WebRequest&lt;/span&gt; &lt;span style="color: rgb(1, 0, 1);"&gt;request&lt;/span&gt;, &lt;/p&gt;    &lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp; 21&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: rgb(64, 0, 128);"&gt;int&lt;/span&gt; &lt;span style="color: rgb(1, 0, 1);"&gt;certificateProblem&lt;/span&gt;)&lt;/p&gt;    &lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp; 22&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;    &lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp; 23&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: rgb(64, 0, 128);"&gt;if&lt;/span&gt; (&lt;span style="color: rgb(1, 0, 1);"&gt;certificateProblem&lt;/span&gt; &lt;span style="color: rgb(46, 83, 209);"&gt;==&lt;/span&gt; &lt;span style="color: rgb(37, 146, 65);"&gt;0&lt;/span&gt; &lt;span style="color: rgb(46, 83, 209);"&gt;||&lt;/span&gt; &lt;/p&gt;    &lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp; 24&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: rgb(1, 0, 1);"&gt;certificateProblem&lt;/span&gt; &lt;span style="color: rgb(46, 83, 209);"&gt;==&lt;/span&gt; &lt;span style="color: rgb(46, 83, 209);"&gt;-&lt;/span&gt;&lt;span style="color: rgb(37, 146, 65);"&gt;2146762487&lt;/span&gt;)&lt;/p&gt;    &lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp; 25&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: rgb(64, 0, 128);"&gt;return&lt;/span&gt; &lt;span style="color: rgb(64, 0, 128);"&gt;true&lt;/span&gt;;&lt;/p&gt;    &lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp; 26&lt;/span&gt;&amp;nbsp;&lt;/p&gt;    &lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp; 27&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: rgb(64, 0, 128);"&gt;return&lt;/span&gt; &lt;span style="color: rgb(64, 0, 128);"&gt;false&lt;/span&gt;;&lt;/p&gt;    &lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp; 28&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;    &lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp; 29&lt;/span&gt; }&lt;/p&gt; &lt;/div&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;p&gt;2) Add the following line to the Application_BeginRequest event or the OnInit event of any page that needs to call a web services that uses a self-signed cert.&amp;nbsp; &lt;/p&gt;  &lt;div style="background: rgb(227, 213, 193) none repeat scroll 0% 0%; font-family: envy code r vs; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: black; font-size: 10pt;"&gt;   &lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(1, 0, 1);"&gt;System&lt;/span&gt;&lt;span style="color: rgb(46, 83, 209);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(1, 0, 1);"&gt;Net&lt;/span&gt;&lt;span style="color: rgb(46, 83, 209);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(1, 0, 1);"&gt;ServicePointManager&lt;/span&gt;&lt;span style="color: rgb(46, 83, 209);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(1, 0, 1);"&gt;CertificatePolicy&lt;/span&gt; &lt;span style="color: rgb(46, 83, 209);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(1, 0, 1);"&gt;New&lt;/span&gt; &lt;span style="color: rgb(1, 0, 1);"&gt;SelfSignedPolicy&lt;/span&gt;&lt;/p&gt; &lt;/div&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;font size="4"&gt;&lt;u&gt;VS2005/2008&lt;/u&gt;&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;1) Create a class files that contains the following code (I recommend calling the file Certificates.cs).&lt;/p&gt;  &lt;div style="background: rgb(227, 213, 193) none repeat scroll 0% 0%; font-family: envy code r vs; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: black; font-size: 10pt;"&gt;   &lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(64, 0, 128);"&gt;using&lt;/span&gt; &lt;span style="color: rgb(1, 0, 1);"&gt;System&lt;/span&gt;&lt;span style="color: rgb(46, 83, 209);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(1, 0, 1);"&gt;Net&lt;/span&gt;&lt;span style="color: rgb(46, 83, 209);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(1, 0, 1);"&gt;Security&lt;/span&gt;;&lt;/p&gt;    &lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(64, 0, 128);"&gt;using&lt;/span&gt; &lt;span style="color: rgb(1, 0, 1);"&gt;System&lt;/span&gt;&lt;span style="color: rgb(46, 83, 209);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(1, 0, 1);"&gt;Security&lt;/span&gt;&lt;span style="color: rgb(46, 83, 209);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(1, 0, 1);"&gt;Cryptography&lt;/span&gt;&lt;span style="color: rgb(46, 83, 209);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(1, 0, 1);"&gt;X509Certificates&lt;/span&gt;;&lt;/p&gt;    &lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&lt;/span&gt;&amp;nbsp;&lt;/p&gt;    &lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(64, 0, 128);"&gt;class&lt;/span&gt; &lt;span style="color: rgb(48, 95, 182);"&gt;Certificates&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&lt;/span&gt; {&lt;/p&gt;    &lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 6&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: rgb(64, 0, 128);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(64, 0, 128);"&gt;static&lt;/span&gt; &lt;span style="color: rgb(64, 0, 128);"&gt;bool&lt;/span&gt; &lt;span style="color: rgb(1, 0, 1);"&gt;ValidateRemoteCertificate&lt;/span&gt;(&lt;span style="color: rgb(64, 0, 128);"&gt;object&lt;/span&gt; &lt;span style="color: rgb(1, 0, 1);"&gt;sender&lt;/span&gt;, &lt;/p&gt;    &lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 7&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: rgb(48, 95, 182);"&gt;X509Certificate&lt;/span&gt; &lt;span style="color: rgb(1, 0, 1);"&gt;certificate&lt;/span&gt;, &lt;/p&gt;    &lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 8&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: rgb(48, 95, 182);"&gt;X509Chain&lt;/span&gt; &lt;span style="color: rgb(1, 0, 1);"&gt;chain&lt;/span&gt;, &lt;/p&gt;    &lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 9&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: rgb(43, 145, 175);"&gt;SslPolicyErrors&lt;/span&gt; &lt;span style="color: rgb(1, 0, 1);"&gt;policyErrors&lt;/span&gt;)&lt;/p&gt;    &lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp; 10&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;    &lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp; 11&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: rgb(147, 122, 66); font-weight: bold;"&gt;//Return True to force the certificate to be accepted.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/p&gt;    &lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp; 12&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: rgb(147, 122, 66); font-weight: bold;"&gt;//Needed so that calling web services with self-signed certs will work.&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp; 13&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: rgb(64, 0, 128);"&gt;return&lt;/span&gt; &lt;span style="color: rgb(64, 0, 128);"&gt;true&lt;/span&gt;;&lt;/p&gt;    &lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp; 14&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;    &lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp; 15&lt;/span&gt; }&lt;/p&gt; &lt;/div&gt;  &lt;p&gt;2) Add the following lines to the Application_BeginRequest event in the global.asx file or the OnInit event of any page that needs to call a web services that uses a self-signed cert.&amp;nbsp; &lt;/p&gt;  &lt;div style="background: rgb(227, 213, 193) none repeat scroll 0% 0%; font-family: envy code r vs; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: black; font-size: 10pt;"&gt;   &lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(64, 0, 128);"&gt;using&lt;/span&gt; &lt;span style="color: rgb(1, 0, 1);"&gt;System&lt;/span&gt;;&lt;/p&gt;    &lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(64, 0, 128);"&gt;using&lt;/span&gt; &lt;span style="color: rgb(1, 0, 1);"&gt;System&lt;/span&gt;&lt;span style="color: rgb(46, 83, 209);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(1, 0, 1);"&gt;Net&lt;/span&gt;;&lt;/p&gt;    &lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(64, 0, 128);"&gt;using&lt;/span&gt; &lt;span style="color: rgb(1, 0, 1);"&gt;System&lt;/span&gt;&lt;span style="color: rgb(46, 83, 209);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(1, 0, 1);"&gt;Net&lt;/span&gt;&lt;span style="color: rgb(46, 83, 209);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(1, 0, 1);"&gt;Security&lt;/span&gt;;&lt;/p&gt;    &lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&lt;/span&gt;&amp;nbsp;&lt;/p&gt;    &lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&lt;/span&gt;&amp;nbsp;&lt;/p&gt;    &lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 6&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(64, 0, 128);"&gt;protected&lt;/span&gt; &lt;span style="color: rgb(64, 0, 128);"&gt;void&lt;/span&gt; &lt;span style="color: rgb(1, 0, 1);"&gt;Application_BeginRequest&lt;/span&gt;(&lt;span style="color: rgb(48, 95, 182);"&gt;Object&lt;/span&gt; &lt;span style="color: rgb(1, 0, 1);"&gt;sender&lt;/span&gt;, &lt;span style="color: rgb(48, 95, 182);"&gt;EventArgs&lt;/span&gt; &lt;span style="color: rgb(1, 0, 1);"&gt;e&lt;/span&gt;)&lt;/p&gt;    &lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 7&lt;/span&gt; {&lt;/p&gt;    &lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 8&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: rgb(48, 95, 182);"&gt;ServicePointManager&lt;/span&gt;&lt;span style="color: rgb(46, 83, 209);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(1, 0, 1);"&gt;ServerCertificateValidationCallback&lt;/span&gt; &lt;span style="color: rgb(46, 83, 209);"&gt;=&lt;/span&gt; &lt;/p&gt;    &lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 9&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: rgb(64, 0, 128);"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;RemoteCertificateValidationCallback&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp; 10&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (&lt;span style="color: rgb(1, 0, 1);"&gt;Certificates&lt;/span&gt;&lt;span style="color: rgb(46, 83, 209);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(1, 0, 1);"&gt;ValidateRemoteCertificate&lt;/span&gt;);&lt;/p&gt;    &lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp; 11&lt;/span&gt; }&lt;/p&gt; &lt;/div&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;u&gt;&lt;font size="4"&gt;Summary&lt;/font&gt;&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;Of course, ignoring the certificate errors within the code could open up a security risk depending on what it is being used for.&amp;nbsp; Therefore, you need to look at each situation this could be used and decide if this is the right approach to take based on the risks.&amp;nbsp; As a developer it is up to you to look at the risks, what problem is being solved and the priority of the issue to determine whether to implement a particular solution.&lt;/p&gt;  &lt;p&gt;Also, in most situations I would wrap the code in the Application_BeginRequest or OnInit functions so that they only run when in a Dev/QA environment.&amp;nbsp; There should not be any reason you would need a production site to access web services running under a self-signed cert (or an invalid certificate).&amp;nbsp; Since this can be done in many different ways, the code to do that is not shown in the examples above.&amp;nbsp; &lt;/p&gt;&lt;p&gt;&lt;div&gt;
&lt;script type="text/javascript"&gt;
var addthis_pub="smehaffie";
var addthis_options="email, print, digg, slashdot, delicious, twitter, live, myspace, facebook, google, stumbleupon, newsvine";
&lt;/script&gt;

&lt;a href="http://www.addthis.com/bookmark.php?v=20" onmouseover="return addthis_open(this, '', '[URL]', '[TITLE]')" onmouseout="addthis_close()" onclick="return addthis_sendto()"&gt;
&lt;img src="http://s7.addthis.com/static/btn/lg-share-en.gif" alt="Share This Post" style="border:0"/&gt;
&lt;/a&gt;

&lt;/div&gt; &lt;br&gt;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7199748" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/smehaffie/archive/tags/General+Software+Development/default.aspx">General Software Development</category><category domain="http://weblogs.asp.net/smehaffie/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://weblogs.asp.net/smehaffie/archive/tags/.Net/default.aspx">.Net</category></item><item><title>LINQ TO SQL and PLINQO</title><link>http://weblogs.asp.net/smehaffie/archive/2009/08/26/linq-to-sql-and-plinqo.aspx</link><pubDate>Wed, 26 Aug 2009 22:09:46 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7182393</guid><dc:creator>smehaffie</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/smehaffie/rsscomments.aspx?PostID=7182393</wfw:commentRss><comments>http://weblogs.asp.net/smehaffie/archive/2009/08/26/linq-to-sql-and-plinqo.aspx#comments</comments><description>&lt;p&gt;From my limited experience with the EF and “LINQ To SQL” I have to agree that “LINQ To SQL” is the way to go if you application or web site only needs to connect to SQL Server databases.&amp;#160; “LINQ To SQL” pretty feature rich as it is and although there will not be any major new features added to it, that does not mean it is not a viable option for .Net developers to use.&amp;#160; “LINQ To SQL” is already used by to many people so it will be a part of the .Net framework for quite some time.&amp;#160; And now developers have a way to get more features using “LINQ To SQL” by using PLINQO. &lt;/p&gt;  &lt;p&gt;PLINQO is a new offering by Codesmith and it adds some functionality that makes “LINQ To SQL” an even better solution.&amp;#160; Although I have not been able to really dive in and play with it yet, based on the information on the web site looks like PLINQO is could become a must have tool for developers who use “LINQ To SQL”.&amp;#160; So even if Microsoft is not going to add functionality to “LINQ To SQL”, it looks like the developers at Codesmith are picking up the torch and going to add functionality through PLINQO.&amp;#160; For more information on PLINQO, visit the web site at &lt;a href="http://plinqo.com"&gt;http://plinqo.com&lt;/a&gt;.&amp;#160; Go ahead, try it out.&lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;After playing with PLINQO, I will do another post to review what I think about about it, but on the surface looks like a very promising.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7182393" width="1" height="1"&gt;</description></item><item><title>Escaping/Unescaping XML Data</title><link>http://weblogs.asp.net/smehaffie/archive/2009/08/16/escaping-unescaping-xml-data.aspx</link><pubDate>Mon, 17 Aug 2009 04:08:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7171078</guid><dc:creator>smehaffie</dc:creator><slash:comments>5</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/smehaffie/rsscomments.aspx?PostID=7171078</wfw:commentRss><comments>http://weblogs.asp.net/smehaffie/archive/2009/08/16/escaping-unescaping-xml-data.aspx#comments</comments><description>
&lt;p&gt;With as popular as XML is, when creating XML files you need to be able to escape certain characters that will not parse correctly if they are not escaped.&amp;nbsp; Until recently I always did this like most other .Net programmers, I wrote a function to do it.&lt;/p&gt;
  &lt;div style="background: rgb(227, 213, 193) none repeat scroll 0% 0%; font-family: envy code r vs; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: black; font-size: 10pt;"&gt;   
&lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(64, 0, 128);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(64, 0, 128);"&gt;static&lt;/span&gt; &lt;span style="color: rgb(64, 0, 128);"&gt;string&lt;/span&gt; &lt;span style="color: rgb(1, 0, 1);"&gt;EscapeXML&lt;/span&gt;(&lt;span style="color: rgb(64, 0, 128);"&gt;this&lt;/span&gt; &lt;span style="color: rgb(64, 0, 128);"&gt;string&lt;/span&gt; &lt;span style="color: rgb(1, 0, 1);"&gt;s&lt;/span&gt;)&lt;/p&gt;
    
&lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&lt;/span&gt; {&lt;/p&gt;
    
&lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: rgb(64, 0, 128);"&gt;if&lt;/span&gt; (&lt;span style="color: rgb(64, 0, 128);"&gt;string&lt;/span&gt;&lt;span style="color: rgb(46, 83, 209);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(1, 0, 1);"&gt;IsNullOrEmpty&lt;/span&gt;(&lt;span style="color: rgb(1, 0, 1);"&gt;s&lt;/span&gt;)) &lt;span style="color: rgb(64, 0, 128);"&gt;return&lt;/span&gt; &lt;span style="color: rgb(1, 0, 1);"&gt;s&lt;/span&gt;;&lt;/p&gt;
    
&lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
    
&lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: rgb(64, 0, 128);"&gt;string&lt;/span&gt; &lt;span style="color: rgb(1, 0, 1);"&gt;returnString&lt;/span&gt; &lt;span style="color: rgb(46, 83, 209);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(1, 0, 1);"&gt;s&lt;/span&gt;;&lt;/p&gt;
    
&lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 6&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: rgb(1, 0, 1);"&gt;returnString&lt;/span&gt; &lt;span style="color: rgb(46, 83, 209);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(1, 0, 1);"&gt;returnString&lt;/span&gt;&lt;span style="color: rgb(46, 83, 209);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(1, 0, 1);"&gt;Replace&lt;/span&gt;(&lt;span style="color: rgb(37, 146, 65); font-weight: bold;"&gt;"'"&lt;/span&gt;, &lt;span style="color: rgb(37, 146, 65); font-weight: bold;"&gt;"&amp;amp;apos;"&lt;/span&gt;);&lt;/p&gt;
    
&lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 7&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: rgb(1, 0, 1);"&gt;returnString&lt;/span&gt; &lt;span style="color: rgb(46, 83, 209);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(1, 0, 1);"&gt;returnString&lt;/span&gt;&lt;span style="color: rgb(46, 83, 209);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(1, 0, 1);"&gt;Replace&lt;/span&gt;(&lt;span style="color: rgb(37, 146, 65); font-weight: bold;"&gt;"\""&lt;/span&gt;, &lt;span style="color: rgb(37, 146, 65); font-weight: bold;"&gt;"&amp;amp;quot;"&lt;/span&gt;);&lt;/p&gt;
    
&lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 8&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: rgb(1, 0, 1);"&gt;returnString&lt;/span&gt; &lt;span style="color: rgb(46, 83, 209);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(1, 0, 1);"&gt;returnString&lt;/span&gt;&lt;span style="color: rgb(46, 83, 209);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(1, 0, 1);"&gt;Replace&lt;/span&gt;(&lt;span style="color: rgb(37, 146, 65); font-weight: bold;"&gt;"&amp;gt;"&lt;/span&gt;, &lt;span style="color: rgb(37, 146, 65); font-weight: bold;"&gt;"&amp;amp;gt;"&lt;/span&gt;);&lt;/p&gt;
    
&lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 9&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: rgb(1, 0, 1);"&gt;returnString&lt;/span&gt; &lt;span style="color: rgb(46, 83, 209);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(1, 0, 1);"&gt;returnString&lt;/span&gt;&lt;span style="color: rgb(46, 83, 209);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(1, 0, 1);"&gt;Replace&lt;/span&gt;(&lt;span style="color: rgb(37, 146, 65); font-weight: bold;"&gt;"&amp;lt;"&lt;/span&gt;, &lt;span style="color: rgb(37, 146, 65); font-weight: bold;"&gt;"&amp;amp;lt;"&lt;/span&gt;);&lt;/p&gt;
    
&lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp; 10&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: rgb(1, 0, 1);"&gt;returnString&lt;/span&gt; &lt;span style="color: rgb(46, 83, 209);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(1, 0, 1);"&gt;returnString&lt;/span&gt;&lt;span style="color: rgb(46, 83, 209);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(1, 0, 1);"&gt;Replace&lt;/span&gt;(&lt;span style="color: rgb(37, 146, 65); font-weight: bold;"&gt;"&amp;amp;"&lt;/span&gt;, &lt;span style="color: rgb(37, 146, 65); font-weight: bold;"&gt;"&amp;amp;amp;"&lt;/span&gt;);&lt;/p&gt;
    
&lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp; 11&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
    
&lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp; 12&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: rgb(64, 0, 128);"&gt;return&lt;/span&gt; &lt;span style="color: rgb(1, 0, 1);"&gt;returnString&lt;/span&gt;;&lt;/p&gt;
    
&lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp; 13&lt;/span&gt; }&lt;/p&gt;
 &lt;/div&gt;  
&lt;p&gt;Recently I came across a function hidden within the .Net framework that does this within on line of code.&amp;nbsp; It is located in the System.Security class.&amp;nbsp; Under the SecurityElement there is a function that called Escape() that takes a string as a parameter.&amp;nbsp; This basically does what the above function does with one line of code.&amp;nbsp; So the function above is simplified to the code below.&lt;/p&gt;
  &lt;div style="background: rgb(227, 213, 193) none repeat scroll 0% 0%; font-family: envy code r vs; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: black; font-size: 10pt;"&gt;   
&lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(64, 0, 128);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(64, 0, 128);"&gt;static&lt;/span&gt; &lt;span style="color: rgb(64, 0, 128);"&gt;string&lt;/span&gt; &lt;span style="color: rgb(1, 0, 1);"&gt;EscapeXML&lt;/span&gt;(&lt;span style="color: rgb(64, 0, 128);"&gt;this&lt;/span&gt; &lt;span style="color: rgb(64, 0, 128);"&gt;string&lt;/span&gt; &lt;span style="color: rgb(1, 0, 1);"&gt;s&lt;/span&gt;)&lt;/p&gt;
    
&lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&lt;/span&gt; {&lt;/p&gt;
    
&lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: rgb(64, 0, 128);"&gt;if&lt;/span&gt; (&lt;span style="color: rgb(64, 0, 128);"&gt;string&lt;/span&gt;&lt;span style="color: rgb(46, 83, 209);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(1, 0, 1);"&gt;IsNullOrEmpty&lt;/span&gt;(&lt;span style="color: rgb(1, 0, 1);"&gt;s&lt;/span&gt;)) &lt;span style="color: rgb(64, 0, 128);"&gt;return&lt;/span&gt; &lt;span style="color: rgb(1, 0, 1);"&gt;s&lt;/span&gt;;&lt;/p&gt;
    
&lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
    
&lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: rgb(64, 0, 128);"&gt;return&lt;/span&gt; &lt;span style="color: rgb(48, 95, 182);"&gt;SecurityElement&lt;/span&gt;&lt;span style="color: rgb(46, 83, 209);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(1, 0, 1);"&gt;Escape&lt;/span&gt;(&lt;span style="color: rgb(1, 0, 1);"&gt;s&lt;/span&gt;);&lt;/p&gt;
    
&lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 6&lt;/span&gt; }&lt;/p&gt;
 &lt;/div&gt;  
&lt;p&gt;So now the only question is how this can be an even better solution.&amp;nbsp; The answer is by using extension methods.&amp;nbsp; You can create a class called StringExtensions the contains the code below.&amp;nbsp; I personally have a PCRExtensions project that I put all my extension methods, that way I can use them in any project that needs them. &lt;/p&gt;
  &lt;div style="background: rgb(227, 213, 193) none repeat scroll 0% 0%; font-family: envy code r vs; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: black; font-size: 10pt;"&gt;   
&lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(64, 0, 128);"&gt;using&lt;/span&gt; &lt;span style="color: rgb(1, 0, 1);"&gt;System&lt;/span&gt;&lt;span style="color: rgb(46, 83, 209);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(1, 0, 1);"&gt;Security&lt;/span&gt;;&lt;/p&gt;
    
&lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
    
&lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(64, 0, 128);"&gt;namespace&lt;/span&gt; &lt;span style="color: rgb(1, 0, 1);"&gt;YourExtensions&lt;/span&gt;&lt;/p&gt;
    
&lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&lt;/span&gt; {&lt;/p&gt;
    
&lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: rgb(64, 0, 128);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(64, 0, 128);"&gt;static&lt;/span&gt; &lt;span style="color: rgb(64, 0, 128);"&gt;class&lt;/span&gt; &lt;span style="color: rgb(48, 95, 182);"&gt;StringExtensions&lt;/span&gt;&lt;/p&gt;
    
&lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 6&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;
    
&lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 7&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: rgb(64, 0, 128);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(64, 0, 128);"&gt;static&lt;/span&gt; &lt;span style="color: rgb(64, 0, 128);"&gt;string&lt;/span&gt; &lt;span style="color: rgb(1, 0, 1);"&gt;EscapeXML&lt;/span&gt;(&lt;span style="color: rgb(64, 0, 128);"&gt;this&lt;/span&gt; &lt;span style="color: rgb(64, 0, 128);"&gt;string&lt;/span&gt; &lt;span style="color: rgb(1, 0, 1);"&gt;s&lt;/span&gt;)&lt;/p&gt;
    
&lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 8&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;
    
&lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 9&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: rgb(64, 0, 128);"&gt;if&lt;/span&gt; (&lt;span style="color: rgb(64, 0, 128);"&gt;string&lt;/span&gt;&lt;span style="color: rgb(46, 83, 209);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(1, 0, 1);"&gt;IsNullOrEmpty&lt;/span&gt;(&lt;span style="color: rgb(1, 0, 1);"&gt;s&lt;/span&gt;)) &lt;span style="color: rgb(64, 0, 128);"&gt;return&lt;/span&gt; &lt;span style="color: rgb(1, 0, 1);"&gt;s&lt;/span&gt;;&lt;/p&gt;
    
&lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp; 10&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
    
&lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp; 11&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: rgb(64, 0, 128);"&gt;return&lt;/span&gt; &lt;span style="color: rgb(46, 83, 209);"&gt;!&lt;/span&gt;&lt;span style="color: rgb(48, 95, 182);"&gt;SecurityElement&lt;/span&gt;&lt;span style="color: rgb(46, 83, 209);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(1, 0, 1);"&gt;IsValidText&lt;/span&gt;(&lt;span style="color: rgb(1, 0, 1);"&gt;s&lt;/span&gt;) &lt;/p&gt;
    
&lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp; 12&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: rgb(46, 83, 209);"&gt;?&lt;/span&gt; &lt;span style="color: rgb(48, 95, 182);"&gt;SecurityElement&lt;/span&gt;&lt;span style="color: rgb(46, 83, 209);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(1, 0, 1);"&gt;Escape&lt;/span&gt;(&lt;span style="color: rgb(1, 0, 1);"&gt;s&lt;/span&gt;) : &lt;span style="color: rgb(1, 0, 1);"&gt;s&lt;/span&gt;;&lt;/p&gt;
    
&lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp; 13&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
    
&lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp; 14&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
    
&lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp; 15&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: rgb(64, 0, 128);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(64, 0, 128);"&gt;static&lt;/span&gt; &lt;span style="color: rgb(64, 0, 128);"&gt;string&lt;/span&gt; &lt;span style="color: rgb(1, 0, 1);"&gt;UnescapeXML&lt;/span&gt;(&lt;span style="color: rgb(64, 0, 128);"&gt;this&lt;/span&gt; &lt;span style="color: rgb(64, 0, 128);"&gt;string&lt;/span&gt; &lt;span style="color: rgb(1, 0, 1);"&gt;s&lt;/span&gt;)&lt;/p&gt;
    
&lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp; 16&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;
    
&lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp; 17&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: rgb(64, 0, 128);"&gt;if&lt;/span&gt; (&lt;span style="color: rgb(64, 0, 128);"&gt;string&lt;/span&gt;&lt;span style="color: rgb(46, 83, 209);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(1, 0, 1);"&gt;IsNullOrEmpty&lt;/span&gt;(&lt;span style="color: rgb(1, 0, 1);"&gt;s&lt;/span&gt;)) &lt;span style="color: rgb(64, 0, 128);"&gt;return&lt;/span&gt; &lt;span style="color: rgb(1, 0, 1);"&gt;s&lt;/span&gt;;&lt;/p&gt;
    
&lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp; 18&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
    
&lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp; 19&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: rgb(64, 0, 128);"&gt;string&lt;/span&gt; &lt;span style="color: rgb(1, 0, 1);"&gt;returnString&lt;/span&gt; &lt;span style="color: rgb(46, 83, 209);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(1, 0, 1);"&gt;s&lt;/span&gt;;&lt;/p&gt;
    
&lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp; 20&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: rgb(1, 0, 1);"&gt;returnString&lt;/span&gt; &lt;span style="color: rgb(46, 83, 209);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(1, 0, 1);"&gt;returnString&lt;/span&gt;&lt;span style="color: rgb(46, 83, 209);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(1, 0, 1);"&gt;Replace&lt;/span&gt;(&lt;span style="color: rgb(37, 146, 65); font-weight: bold;"&gt;"&amp;amp;apos;"&lt;/span&gt;, &lt;span style="color: rgb(37, 146, 65); font-weight: bold;"&gt;"'"&lt;/span&gt;);&lt;/p&gt;
    
&lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp; 21&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: rgb(1, 0, 1);"&gt;returnString&lt;/span&gt; &lt;span style="color: rgb(46, 83, 209);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(1, 0, 1);"&gt;returnString&lt;/span&gt;&lt;span style="color: rgb(46, 83, 209);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(1, 0, 1);"&gt;Replace&lt;/span&gt;(&lt;span style="color: rgb(37, 146, 65); font-weight: bold;"&gt;"&amp;amp;quot;"&lt;/span&gt;, &lt;span style="color: rgb(37, 146, 65); font-weight: bold;"&gt;"\""&lt;/span&gt;);&lt;/p&gt;
    
&lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp; 22&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: rgb(1, 0, 1);"&gt;returnString&lt;/span&gt; &lt;span style="color: rgb(46, 83, 209);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(1, 0, 1);"&gt;returnString&lt;/span&gt;&lt;span style="color: rgb(46, 83, 209);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(1, 0, 1);"&gt;Replace&lt;/span&gt;(&lt;span style="color: rgb(37, 146, 65); font-weight: bold;"&gt;"&amp;amp;gt;"&lt;/span&gt;, &lt;span style="color: rgb(37, 146, 65); font-weight: bold;"&gt;"&amp;gt;"&lt;/span&gt;);&lt;/p&gt;
    
&lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp; 23&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: rgb(1, 0, 1);"&gt;returnString&lt;/span&gt; &lt;span style="color: rgb(46, 83, 209);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(1, 0, 1);"&gt;returnString&lt;/span&gt;&lt;span style="color: rgb(46, 83, 209);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(1, 0, 1);"&gt;Replace&lt;/span&gt;(&lt;span style="color: rgb(37, 146, 65); font-weight: bold;"&gt;"&amp;amp;lt;"&lt;/span&gt;, &lt;span style="color: rgb(37, 146, 65); font-weight: bold;"&gt;"&amp;lt;"&lt;/span&gt;);&lt;/p&gt;
    
&lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp; 24&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: rgb(1, 0, 1);"&gt;returnString&lt;/span&gt; &lt;span style="color: rgb(46, 83, 209);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(1, 0, 1);"&gt;returnString&lt;/span&gt;&lt;span style="color: rgb(46, 83, 209);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(1, 0, 1);"&gt;Replace&lt;/span&gt;(&lt;span style="color: rgb(37, 146, 65); font-weight: bold;"&gt;"&amp;amp;amp;"&lt;/span&gt;, &lt;span style="color: rgb(37, 146, 65); font-weight: bold;"&gt;"&amp;amp;"&lt;/span&gt;);&lt;/p&gt;
    
&lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp; 25&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
    
&lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp; 26&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: rgb(64, 0, 128);"&gt;return&lt;/span&gt; &lt;span style="color: rgb(1, 0, 1);"&gt;returnString&lt;/span&gt;;&lt;/p&gt;
    
&lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp; 27&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
    
&lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp; 28&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
    
&lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp; 29&lt;/span&gt; }&lt;/p&gt;
 &lt;/div&gt;  
&lt;p&gt;So now that you have the above extension methods written for string objects, you can call them by using them just like any other built in function.&amp;nbsp; And the nice thing is, they even show up in intellisense so you can just pick the method from the list just as if they were part of the framework.&amp;nbsp; This is what makes extension methods so powerful.&lt;/p&gt;
  &lt;div style="background: rgb(227, 213, 193) none repeat scroll 0% 0%; font-family: envy code r vs; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: black; font-size: 10pt;"&gt;   
&lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp; 1&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(64, 0, 128);"&gt;string&lt;/span&gt; &lt;span style="color: rgb(1, 0, 1);"&gt;xmlUnescapedText&lt;/span&gt; &lt;span style="color: rgb(46, 83, 209);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(37, 146, 65); font-weight: bold;"&gt;"Ben &amp;amp; Jerry's"&lt;/span&gt;;&lt;/p&gt;
    
&lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp; 2&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(1, 0, 1);"&gt;xmlUnescapedText&lt;/span&gt;&lt;span style="color: rgb(46, 83, 209);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(1, 0, 1);"&gt;EscapeXML&lt;/span&gt;();&amp;nbsp; &lt;span style="color: rgb(147, 122, 66); font-weight: bold;"&gt;//returns "Ben &amp;amp;amp; Jerry&amp;amp;apos;s"&lt;/span&gt;&lt;/p&gt;
    
&lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp; 3&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
    
&lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp; 4&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(64, 0, 128);"&gt;string&lt;/span&gt; &lt;span style="color: rgb(1, 0, 1);"&gt;xmlEscapedText&lt;/span&gt; &lt;span style="color: rgb(46, 83, 209);"&gt;=&lt;/span&gt; &lt;span style="color: rgb(37, 146, 65); font-weight: bold;"&gt;"Ben &amp;amp;amp; Jerry&amp;amp;apos;s"&lt;/span&gt;;&lt;/p&gt;
    
&lt;p style="margin: 0px;"&gt;&lt;span style="background: rgb(237, 207, 163) none repeat scroll 0% 0%; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; color: rgb(166, 138, 74);"&gt;&amp;nbsp;&amp;nbsp; 5&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(1, 0, 1);"&gt;xmlEscapedText&lt;/span&gt;&lt;span style="color: rgb(46, 83, 209);"&gt;.&lt;/span&gt;&lt;span style="color: rgb(1, 0, 1);"&gt;UnescapeXML&lt;/span&gt;();&amp;nbsp; &lt;span style="color: rgb(147, 122, 66); font-weight: bold;"&gt;//returns "Ben &amp;amp; Jerry's"&lt;/span&gt;&lt;/p&gt;
 &lt;/div&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;div&gt;
&lt;script type="text/javascript"&gt;
var addthis_pub="smehaffie";
var addthis_options="email, print, digg, slashdot, delicious, twitter, live, myspace, facebook, google, stumbleupon, newsvine";
&lt;/script&gt;

&lt;a href="http://www.addthis.com/bookmark.php?v=20" onmouseover="return addthis_open(this, '', '[URL]', '[TITLE]')" onmouseout="addthis_close()" onclick="return addthis_sendto()"&gt;
&lt;img src="http://s7.addthis.com/static/btn/lg-share-en.gif" alt="Share This Post" style="border:0"/&gt;
&lt;/a&gt;

&lt;/div&gt; &lt;br&gt;&lt;/div&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7171078" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/smehaffie/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://weblogs.asp.net/smehaffie/archive/tags/.Net/default.aspx">.Net</category></item><item><title>Selected Version Property - .Net References</title><link>http://weblogs.asp.net/smehaffie/archive/2009/04/17/selected-version-property-net-references.aspx</link><pubDate>Fri, 17 Apr 2009 21:06:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7049121</guid><dc:creator>smehaffie</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/smehaffie/rsscomments.aspx?PostID=7049121</wfw:commentRss><comments>http://weblogs.asp.net/smehaffie/archive/2009/04/17/selected-version-property-net-references.aspx#comments</comments><description>&lt;p&gt;When you work on a team that is working on a single project this setting comes in really handy so builds do not break.&amp;nbsp; The best use for it is when there are some 3rd party tools where all the team members might have had a chance to upgrade to the latest version.&amp;nbsp; &lt;/p&gt;  &lt;p&gt;A good example of this just happened on a project I am working on.&amp;nbsp; Recently I upgraded to Resharper 4.5 and Gallic/MbUnit 3.0.6 and all my Unit test project compiled and ran.&amp;nbsp; But today when I got the latest source for another project, it would not compile the Unit Test projects (it did not recognize the TestFixture / Test attributes, etc).&lt;/p&gt;  &lt;p&gt;So instead of deleting the Gallio/MBUnit references and recreating them, which could break the builds of other developers who had not updated to the latest version of Gallio/MBUnit, the solution was to set the “Specific Version” flag to false. After doing that the references showed as valid, the project compile and all the MBUnit test ran. &lt;/p&gt;  &lt;p&gt;Before today I did not know about this setting or what it did, but I can see definite uses for it (especially in a team environment). &lt;font color="#ff0000"&gt;There is one caveat to using this setting, it is only a build-time directive (for Visual Studio). It has no effect on the runtime version resolution of the referenced assembly&lt;/font&gt;.&amp;nbsp; So although the project build you could still get runtime issues.&amp;nbsp; This is not a major deal and can be handled by creating assembly bindings for the assembly in question so that all reference to an earlier version automatically point to the latest version (but that is the topic of another blog post).&lt;/p&gt;  &lt;p&gt;Here is a very good link on not only this issue, but also many other things to keep in mind when working with assemblies and multiple versions of assemblies.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.code-magazine.com/article.aspx?quickid=0507041&amp;amp;page=3" title="http://www.code-magazine.com/article.aspx?quickid=0507041&amp;amp;page=3" mce_href="http://www.code-magazine.com/article.aspx?quickid=0507041&amp;amp;page=3"&gt;http://www.code-magazine.com/article.aspx?quickid=0507041&amp;amp;page=3&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;p&gt;&lt;div&gt;
&lt;script type="text/javascript"&gt;
var addthis_pub="smehaffie";
var addthis_options="email, print, digg, slashdot, delicious, twitter, live, myspace, facebook, google, stumbleupon, newsvine";
&lt;/script&gt;

&lt;a href="http://www.addthis.com/bookmark.php?v=20" onmouseover="return addthis_open(this, '', '[URL]', '[TITLE]')" onmouseout="addthis_close()" onclick="return addthis_sendto()"&gt;
&lt;img src="http://s7.addthis.com/static/btn/lg-share-en.gif" alt="Share This Post" style="border:0"/&gt;
&lt;/a&gt;

&lt;/div&gt;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7049121" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/smehaffie/archive/tags/Visual+Studio/default.aspx">Visual Studio</category></item><item><title>Random Number in C#, Be careful of some of the samples you find.</title><link>http://weblogs.asp.net/smehaffie/archive/2009/03/15/random-number-in-c-be-careful-of-some-of-the-samples-you-find.aspx</link><pubDate>Mon, 16 Mar 2009 04:04:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6967184</guid><dc:creator>smehaffie</dc:creator><slash:comments>17</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/smehaffie/rsscomments.aspx?PostID=6967184</wfw:commentRss><comments>http://weblogs.asp.net/smehaffie/archive/2009/03/15/random-number-in-c-be-careful-of-some-of-the-samples-you-find.aspx#comments</comments><description>&lt;p&gt;I recently came across this code on the internet for generating a random number with C#.&lt;/p&gt;  &lt;div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; line-height: 12pt; background-color: rgb(244, 244, 244); width: 97.5%; font-family: consolas,'Courier New',courier,monospace; height: 97px; font-size: 8pt; cursor: text;"&gt;   &lt;div style="border-style: none; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;     &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   1:&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;private&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;static&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;int&lt;/span&gt; RandomNumber(&lt;span style="color: rgb(0, 0, 255);"&gt;int&lt;/span&gt; min, &lt;span style="color: rgb(0, 0, 255);"&gt;int&lt;/span&gt; max)&lt;/pre&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   3:&lt;/span&gt;    Random random = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; Random();&lt;/pre&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   4:&lt;/span&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt; random.Next(min, max);&lt;/pre&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; height: 16px; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   5:&lt;/span&gt; }&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;The problem with this code is that for a novice developer (and maybe even some advance developers) it can be misleading and in some instance will not work.&amp;nbsp; Take for instance the following code…&lt;/p&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;

&lt;p&gt;The issue with this is not immediately obvious, but if you remember one thing about the Random object in C# is that when you do not pass it any parameters is uses a time based seed.&amp;nbsp; In addition, if you use the same seed for an new instance the same numbers will be generated, thus they number really are not random. The same is also true for the Random.Next function, if called within the same time the same number as previous will be generated.&amp;nbsp; So in the case of the function above, the for loop can go through the loop 4-5 times within a millisecond, so that means the same “random” number will be generated.&amp;nbsp; So this function really does not generate a real random ID (since the same characters are repeated 4-5 times).&lt;/p&gt;

&lt;div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; line-height: 12pt; background-color: rgb(244, 244, 244); width: 97.5%; font-family: consolas,'Courier New',courier,monospace; height: 509px; font-size: 8pt; cursor: text;"&gt;
  &lt;div style="border-style: none; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;
    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   1:&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;static&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt; GenerateID(&lt;span style="color: rgb(0, 0, 255);"&gt;int&lt;/span&gt; MinSize, &lt;span style="color: rgb(0, 0, 255);"&gt;int&lt;/span&gt; MaxSize)&lt;/pre&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   3:&lt;/span&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt; stRefID = String.Empty;&lt;/pre&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   4:&lt;/span&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;int&lt;/span&gt; iChosenMaxSize = RandomNumber(MinSize, MaxSize);&lt;/pre&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   5:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   6:&lt;/span&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;for&lt;/span&gt; (&lt;span style="color: rgb(0, 0, 255);"&gt;int&lt;/span&gt; x = 1; x &amp;lt;= iChosenMaxSize; x++)&lt;/pre&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   7:&lt;/span&gt;    {&lt;/pre&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   8:&lt;/span&gt;       &lt;span style="color: rgb(0, 0, 255);"&gt;int&lt;/span&gt; iCharType = RandomNumber(1, 3);&lt;/pre&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   9:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  10:&lt;/span&gt;       &lt;span style="color: rgb(0, 0, 255);"&gt;switch&lt;/span&gt; (iCharType) &lt;/pre&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  11:&lt;/span&gt;       {&lt;/pre&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  12:&lt;/span&gt;          &lt;span style="color: rgb(0, 0, 255);"&gt;case&lt;/span&gt; 1:&lt;/pre&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  13:&lt;/span&gt;          {&lt;/pre&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  14:&lt;/span&gt;             stRefID += &lt;span style="color: rgb(0, 0, 255);"&gt;char&lt;/span&gt;.ConvertFromUtf32(RandomNumber(48, 57));&lt;/pre&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  15:&lt;/span&gt;             &lt;span style="color: rgb(0, 0, 255);"&gt;break&lt;/span&gt;;&lt;/pre&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  16:&lt;/span&gt;          }&lt;/pre&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  17:&lt;/span&gt;          &lt;span style="color: rgb(0, 0, 255);"&gt;case&lt;/span&gt; 2:&lt;/pre&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  18:&lt;/span&gt;          {&lt;/pre&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  19:&lt;/span&gt;             stRefID += &lt;span style="color: rgb(0, 0, 255);"&gt;char&lt;/span&gt;.ConvertFromUtf32(RandomNumber(65, 90));&lt;/pre&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  20:&lt;/span&gt;             &lt;span style="color: rgb(0, 0, 255);"&gt;break&lt;/span&gt;;&lt;/pre&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  21:&lt;/span&gt;          }&lt;/pre&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  22:&lt;/span&gt;          &lt;span style="color: rgb(0, 0, 255);"&gt;case&lt;/span&gt; 3:&lt;/pre&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  23:&lt;/span&gt;          {&lt;/pre&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  24:&lt;/span&gt;             stRefID += &lt;span style="color: rgb(0, 0, 255);"&gt;char&lt;/span&gt;.ConvertFromUtf32(RandomNumber(97, 122));&lt;/pre&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  25:&lt;/span&gt;             &lt;span style="color: rgb(0, 0, 255);"&gt;break&lt;/span&gt;;&lt;/pre&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  26:&lt;/span&gt;          }&lt;/pre&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  27:&lt;/span&gt;       }&lt;/pre&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  28:&lt;/span&gt;    }&lt;/pre&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  29:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  30:&lt;/span&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt; stRefID; &lt;/pre&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  31:&lt;/span&gt; }&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;So the code that does what is really needed cannot use the RandomNumber function that I found on the internet.&amp;nbsp; Below is how the the function above can be written not using the RandomNumber function to do what is expected.&lt;/p&gt;

&lt;div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; line-height: 12pt; background-color: rgb(244, 244, 244); width: 97.5%; font-family: consolas,'Courier New',courier,monospace; height: 559px; font-size: 8pt; cursor: text;"&gt;
  &lt;div style="border-style: none; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;
    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   1:&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;static&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt; GenerateID(&lt;span style="color: rgb(0, 0, 255);"&gt;int&lt;/span&gt; MinSize, &lt;span style="color: rgb(0, 0, 255);"&gt;int&lt;/span&gt; MaxSize)&lt;/pre&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   3:&lt;/span&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt; stRefID = String.Empty;&lt;/pre&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   4:&lt;/span&gt;    Random random = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; Random();&lt;/pre&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   5:&lt;/span&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;int&lt;/span&gt; iChosenMaxSize = random.Next(MinSize, MaxSize); &lt;/pre&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   6:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   7:&lt;/span&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;for&lt;/span&gt; (&lt;span style="color: rgb(0, 0, 255);"&gt;int&lt;/span&gt; x = 1; x &amp;lt;= iChosenMaxSize; x++)&lt;/pre&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   8:&lt;/span&gt;    {&lt;/pre&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   9:&lt;/span&gt;       &lt;span style="color: rgb(0, 0, 255);"&gt;int&lt;/span&gt; iCharType = random.Next(1, 3);&lt;/pre&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  10:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  11:&lt;/span&gt;       &lt;span style="color: rgb(0, 0, 255);"&gt;switch&lt;/span&gt; (iCharType)&lt;/pre&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  12:&lt;/span&gt;       {&lt;/pre&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  13:&lt;/span&gt;          &lt;span style="color: rgb(0, 0, 255);"&gt;case&lt;/span&gt; 1:&lt;/pre&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  14:&lt;/span&gt;          {&lt;/pre&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  15:&lt;/span&gt;             stRefID += &lt;span style="color: rgb(0, 0, 255);"&gt;char&lt;/span&gt;.ConvertFromUtf32(random.Next(48, 57));&lt;/pre&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  16:&lt;/span&gt;             &lt;span style="color: rgb(0, 0, 255);"&gt;break&lt;/span&gt;;&lt;/pre&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  17:&lt;/span&gt;          }&lt;/pre&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  18:&lt;/span&gt;          &lt;span style="color: rgb(0, 0, 255);"&gt;case&lt;/span&gt; 2:&lt;/pre&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  19:&lt;/span&gt;          {&lt;/pre&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  20:&lt;/span&gt;             stRefID += &lt;span style="color: rgb(0, 0, 255);"&gt;char&lt;/span&gt;.ConvertFromUtf32(random.Next(65, 90));&lt;/pre&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  21:&lt;/span&gt;             &lt;span style="color: rgb(0, 0, 255);"&gt;break&lt;/span&gt;;&lt;/pre&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  22:&lt;/span&gt;          }&lt;/pre&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  23:&lt;/span&gt;          &lt;span style="color: rgb(0, 0, 255);"&gt;case&lt;/span&gt; 3:&lt;/pre&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  24:&lt;/span&gt;          {&lt;/pre&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  25:&lt;/span&gt;             stRefID += &lt;span style="color: rgb(0, 0, 255);"&gt;char&lt;/span&gt;.ConvertFromUtf32(random.Next(97, 122));&lt;/pre&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  26:&lt;/span&gt;             &lt;span style="color: rgb(0, 0, 255);"&gt;break&lt;/span&gt;;&lt;/pre&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  27:&lt;/span&gt;          }&lt;/pre&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  28:&lt;/span&gt;       }&lt;/pre&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  29:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  30:&lt;/span&gt;       System.Threading.Thread.Sleep(1);&lt;/pre&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  31:&lt;/span&gt;    }&lt;/pre&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  32:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: white; width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  33:&lt;/span&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt; stRefID; &lt;/pre&gt;

    &lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; line-height: 12pt; background-color: rgb(244, 244, 244); width: 100%; font-family: consolas,'Courier New',courier,monospace; color: black; font-size: 8pt;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  34:&lt;/span&gt; }&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;The 2 keys to the update function are:&lt;/p&gt;

&lt;p&gt;1) The Random() object is only instantiated once so the seed is only set once.&lt;/p&gt;

&lt;p&gt;2) The addition of the Thread.Sleep(1) call between each of the time through the loop.&amp;nbsp; This makes sure that when the Next function is called the time has changed so that the number generated will not be the same as previously generated.&lt;/p&gt;

&lt;p&gt;This is not a knock on the sample code I found, since it would work in certain instances.&amp;nbsp; But just a warning to be aware that when downloading code samples (even if they get good reviews), might not work in the situation that you need it for and IMO need to be tested even more than code you wrote yourself.&lt;/p&gt;&lt;p&gt;&lt;div&gt;
&lt;script type="text/javascript"&gt;
var addthis_pub="smehaffie";
var addthis_options="email, print, digg, slashdot, delicious, twitter, live, myspace, facebook, google, stumbleupon, newsvine";
&lt;/script&gt;

&lt;a href="http://www.addthis.com/bookmark.php?v=20" onmouseover="return addthis_open(this, '', '[URL]', '[TITLE]')" onmouseout="addthis_close()" onclick="return addthis_sendto()"&gt;
&lt;img src="http://s7.addthis.com/static/btn/lg-share-en.gif" alt="Share This Post" style="border:0"/&gt;
&lt;/a&gt;

&lt;/div&gt; &lt;br&gt;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6967184" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/smehaffie/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://weblogs.asp.net/smehaffie/archive/tags/.Net/default.aspx">.Net</category></item><item><title>Social Networking Links using “AddThis” In Community Server Based Blogs</title><link>http://weblogs.asp.net/smehaffie/archive/2009/02/28/social-networking-links-using-addthis-in-community-server-based-blogs.aspx</link><pubDate>Sun, 01 Mar 2009 03:28:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6932514</guid><dc:creator>smehaffie</dc:creator><slash:comments>17</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/smehaffie/rsscomments.aspx?PostID=6932514</wfw:commentRss><comments>http://weblogs.asp.net/smehaffie/archive/2009/02/28/social-networking-links-using-addthis-in-community-server-based-blogs.aspx#comments</comments><description>&lt;p&gt;With the popularity of “Social Networking” it is becoming a popular feature to make it easy for user to Bookmark/Share blogs, articles, etc that they read online.&amp;nbsp; Since this feature is not built into Community Server, you have to implement this yourself and it really is not hard to do.&amp;nbsp; Since &lt;a href="http://www.asp.net" mce_href="http://www.asp.net"&gt;www.asp.net&lt;/a&gt; is uses a very customized version of Community Server the implementation described below can&amp;nbsp; be used on your blog hosted on &lt;a href="http://www.asp.net" mce_href="http://www.asp.net"&gt;www.asp.net&lt;/a&gt; .&lt;/p&gt;  &lt;p&gt;There is another way to implement this without using the AddThis service (but that is another blog topic).&amp;nbsp; The benefits of using the AddThis service is that it allows you to track what social networking site are used by the readers of your blog to bookmark/share what they have read on you blog.&amp;nbsp;&amp;nbsp; This blog covers setting up a basic “AddThis” button, there are numerous customizations you can do that are explained on &lt;a href="http://www.addthis.com" mce_href="http://www.addthis.com"&gt;http://www.addthis.com&lt;/a&gt;.&amp;nbsp; The one customization I did to was to limit what social network links show in the main list (addthis_options).&lt;/p&gt;  &lt;p&gt;1) Create an account on &lt;a href="http://www.addthis.com" mce_href="http://www.addthis.com"&gt;www.addthis.com&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;2) Generate the script for you button.&amp;nbsp; Below is an example of the code that is generated.&lt;/p&gt;  &lt;table style="margin-left: 15px;" width="585" border="1" cellpadding="2" cellspacing="0"&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign="top" width="583"&gt;         &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt; &amp;lt;&lt;/span&gt;&lt;span class="html"&gt;div&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;&lt;span class="kwrd"&gt; &amp;lt;&lt;/span&gt;&lt;span class="html"&gt;script&lt;/span&gt; &lt;span class="attr"&gt;type&lt;/span&gt;&lt;span class="kwrd"&gt;="text/javascript"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;&lt;span class="kwrd"&gt;    var&lt;/span&gt; addthis_pub=&lt;span class="str"&gt;"{Your AddThis UserID"&lt;/span&gt;;&lt;br&gt;&lt;span class="kwrd"&gt;    var&lt;/span&gt; addthis_options=&lt;span class="str"&gt;"email, print, digg, slashdot, delicious, twitter, live, &lt;br&gt;                         myspace, facebook, &lt;/span&gt;&lt;span class="str"&gt;google, stumbleupon, newsvine"&lt;/span&gt;;&lt;br&gt;&lt;span class="kwrd"&gt; &amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;script&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt; &amp;lt;a href=&lt;span class="str"&gt;"http://www.addthis.com/bookmark.php?v=20"&lt;/span&gt; &lt;br&gt;      onmouseover=&lt;span class="str"&gt;"return addthis_open(this, '', '[URL]', '[TITLE]')"&lt;/span&gt; &lt;br&gt;      onmouseout=&lt;span class="str"&gt;"addthis_close()"&lt;/span&gt;  &lt;br&gt;      onclick=&lt;span class="str"&gt;"return addthis_sendto()"&lt;/span&gt;&amp;gt;&lt;br&gt;      &amp;lt;img src=&lt;span class="str"&gt;"http://s7.addthis.com/static/btn/lg-share-en.gif"&lt;/span&gt; &lt;br&gt;           width=&lt;span class="str"&gt;"125"&lt;/span&gt; height=&lt;span class="str"&gt;"16"&lt;/span&gt; alt=&lt;span class="str"&gt;"Share This Post"&lt;/span&gt; style=&lt;span class="str"&gt;"border:0"&lt;/span&gt;/&amp;gt;&lt;br&gt; &amp;lt;/a&amp;gt;&lt;br&gt; &amp;lt;script type=&lt;span class="str"&gt;"text/javascript"&lt;/span&gt; &lt;br&gt;         src=&lt;span class="str"&gt;"http://s7.addthis.com/js/200/addthis_widget.js"&lt;/span&gt;&amp;gt;&lt;br&gt;&lt;span class="kwrd"&gt; &amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;script&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;&lt;span class="kwrd"&gt; &amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;div&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
        &lt;style type="text/css"&gt;

























.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;&lt;/table&gt;

&lt;div&gt;
  &lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;/div&gt;

&lt;blockquote&gt;
  &lt;p&gt;* You could just cut/paste this code into a snippet but due to the 500 character limit for snippet text this is not suggested.&amp;nbsp; There is no validation on the field so if the text is &amp;gt; 500 character it just truncates the text.&amp;nbsp; This can cause invalid HTML (which can mess up the rendering of the snippet maintenance page (edit/delete buttons not shown, not snippets after bad snippet show, etc).&amp;nbsp; Therefore follow the remaining steps to get around the 500 character limit. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;3) Create the follow snippets for you blog (Controls Panel –&amp;gt; Manage Content –&amp;gt; Manage Snippets).&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;a) Create a new snippet called xAddThisInLineScript and put the following code from above into the text field.&lt;/p&gt;

  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;   &amp;lt;&lt;/span&gt;&lt;span class="html"&gt;script&lt;/span&gt; &lt;span class="attr"&gt;type&lt;/span&gt;&lt;span class="kwrd"&gt;="text/javascript"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;&lt;span class="kwrd"&gt;      var&lt;/span&gt; addthis_pub=&lt;span class="str"&gt;"{Your AddThis UserID"&lt;/span&gt;;&lt;br&gt;&lt;span class="kwrd"&gt;      var&lt;/span&gt; addthis_options=&lt;span class="str"&gt;"email, print, digg, slashdot, delicious, twitter, live, &lt;br&gt;                           myspace, &lt;/span&gt;&lt;span class="str"&gt;facebook, &lt;/span&gt;&lt;span class="str"&gt;google, stumbleupon, newsvine"&lt;/span&gt;;&lt;br&gt;&lt;span class="kwrd"&gt;   &amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;script&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;p&gt;b) Create a new snippet called xAddThis and put the following code from&amp;nbsp; above into the text field.&lt;/p&gt;

  &lt;pre class="csharpcode"&gt;   &amp;lt;a href=&lt;span class="str"&gt;"http://www.addthis.com/bookmark.php?v=20"&lt;/span&gt; &lt;br&gt;      onmouseover=&lt;span class="str"&gt;"return addthis_open(this, '', '[URL]', '[TITLE]') &lt;br&gt;      &lt;/span&gt;onmouseout=&lt;span class="str"&gt;"addthis_close()"&lt;/span&gt;  &lt;br&gt;      onclick=&lt;span class="str"&gt;"return addthis_sendto()"&lt;/span&gt;&amp;gt;&lt;br&gt;      &amp;lt;img src=&lt;span class="str"&gt;"http://s7.addthis.com/static/btn/lg-share-en.gif"&lt;/span&gt; &lt;br&gt;           width=&lt;span class="str"&gt;"125"&lt;/span&gt; height=&lt;span class="str"&gt;"16"&lt;/span&gt; alt=&lt;span class="str"&gt;"Share This Post"&lt;/span&gt; style=&lt;span class="str"&gt;"border:0"&lt;/span&gt;/&amp;gt;&lt;br&gt;   &amp;lt;/a&amp;gt;&lt;/pre&gt;

  &lt;p&gt;c) Create a new snippet called AddThisButton and put the following code in the text field.&lt;/p&gt;

  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;   &amp;lt;&lt;/span&gt;&lt;span class="html"&gt;div&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;      [xAddThisInlineScript]&lt;br&gt;      [xAddThisLink]&lt;br&gt;&lt;span class="kwrd"&gt;   &amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;div&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
  &lt;style type="text/css"&gt;



















.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;/blockquote&gt;

&lt;p&gt;4) Now the final external line of the generated script can only exists once per page.&amp;nbsp; Therefore go to Controls Panel –&amp;gt; Global Settings –&amp;gt; Title, Description and News.&amp;nbsp; Enter the following code into the “Raw Header” field.&lt;/p&gt;

&lt;pre class="csharpcode"&gt;   &amp;lt;script type=&lt;span class="str"&gt;"text/javascript"&lt;/span&gt; &lt;br&gt;      src=&lt;span class="str"&gt;"http://s7.addthis.com/js/200/addthis_widget.js"&lt;/span&gt;&amp;gt;&lt;br&gt;   &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;script&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;That is all that needs to be done to setup your blog to be able to easily add the “AddThis” link to the bottom of every post.&amp;nbsp; Now all you need to do is put “[AddThisButton]” at the end of each blog you write.&amp;nbsp; Although these instruction are for blogs created in Community Server, there should be enough information here to implement this in other blogging engines.&lt;/p&gt;

&lt;p&gt;You can see how this works by seeing the link I have created at the bottom of this blog.&lt;/p&gt;

&lt;p&gt;&lt;div&gt;
&lt;script type="text/javascript"&gt;
var addthis_pub="smehaffie";
var addthis_options="email, print, digg, slashdot, delicious, twitter, live, myspace, facebook, google, stumbleupon, newsvine";
&lt;/script&gt;

&lt;a href="http://www.addthis.com/bookmark.php?v=20" onmouseover="return addthis_open(this, '', '[URL]', '[TITLE]')" onmouseout="addthis_close()" onclick="return addthis_sendto()"&gt;
&lt;img src="http://s7.addthis.com/static/btn/lg-share-en.gif" alt="Share This Post" style="border:0"/&gt;
&lt;/a&gt;

&lt;/div&gt;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6932514" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/smehaffie/archive/tags/Social+Networking/default.aspx">Social Networking</category><category domain="http://weblogs.asp.net/smehaffie/archive/tags/WebLogs+-+Tips+And+Tricks/default.aspx">WebLogs - Tips And Tricks</category><category domain="http://weblogs.asp.net/smehaffie/archive/tags/General+Software+Development/default.aspx">General Software Development</category></item></channel></rss>