<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/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>PeteL's Blog : Code Samples</title><link>http://blogs.msdn.com/petel/archive/tags/Code+Samples/default.aspx</link><description>Tags: Code Samples</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Setting X-UA-Compatible with ASP.NET Pages</title><link>http://blogs.msdn.com/petel/archive/2009/04/15/setting-x-ua-compatible-with-asp-net-pages.aspx</link><pubDate>Wed, 15 Apr 2009 18:47:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9551011</guid><dc:creator>PeteL</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/petel/comments/9551011.aspx</comments><wfw:commentRss>http://blogs.msdn.com/petel/commentrss.aspx?PostID=9551011</wfw:commentRss><description>&lt;P&gt;I got an email today asking about the best way to go about adding the X-UA-Compatible tags on ASP.NET pages where you’ve got a master page, and may want to over ride the X-UA-Compatible tag in some content pages, but not others.&lt;/P&gt;
&lt;P&gt;After playing around with it in Visual Studio for a few minutes, I pulled together the following scenarios:&lt;/P&gt;
&lt;H2&gt;Access To The Server&lt;/H2&gt;
&lt;P&gt;The optimal way to do this, if you have server level access, is to add the IE=EmulateIE7 as an HTTP Response Header from the server. Then, any pages served from that server will be rendered in IE7 mode. If Internet Explorer finds the X-UA-Compatible tag in both the HTTP Response Header, and as a META tag, the META tag will win out. Thus, if you've added the IE=EmulateIE7 to the server, you can over ride it by using the following code snippet:&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Consolas&gt;protected void Page_Load(object sender, EventArgs e) &lt;BR&gt;{ &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; HtmlMeta xuac = new HtmlMeta(); &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xuac.HttpEquiv = "X-UA-Compatible"; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xuac.Content = "IE=EmulateIE8"; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Header.Controls.AddAt(0, xuac); &lt;BR&gt;}&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;One quick note about the Page_Load method, you'll note I use the Header.Controls.AddAt(0, xuac) method. The X-UA-Compatible tag needs to occur BEFORE any code on the page is run, if it doesn't IE will ignore the X-UA-Compatible tag; so it's best to makes sure this is the first tag on the page.&lt;/P&gt;
&lt;H2&gt;No Server Access&lt;/H2&gt;
&lt;P&gt;If you don't have access to the server, and you want to put the X-UA-Compatible tag in the ASP.NET MASTER page, you could do something like this:&lt;/P&gt;
&lt;P&gt;In the master page, I'd create a Content Place Holder:&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Consolas&gt;&amp;lt;asp:ContentPlaceHolder ID="cphMeta" runat="server"&amp;gt; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" /&amp;gt; &lt;BR&gt;&amp;lt;/asp:ContentPlaceHolder&amp;gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;Then, in the individual pages, where you want to override, and go to IE8 standards, you'd insert&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Consolas&gt;&amp;lt;asp:Content ID="Content1" ContentPlaceHolderID="cphMeta" runat="server"&amp;gt; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" /&amp;gt; &lt;BR&gt;&amp;lt;/asp:Content&amp;gt;&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9551011" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/petel/archive/tags/Code+Samples/default.aspx">Code Samples</category><category domain="http://blogs.msdn.com/petel/archive/tags/share/default.aspx">share</category><category domain="http://blogs.msdn.com/petel/archive/tags/ie/default.aspx">ie</category><category domain="http://blogs.msdn.com/petel/archive/tags/web+design/default.aspx">web design</category><category domain="http://blogs.msdn.com/petel/archive/tags/Internet+Explorer/default.aspx">Internet Explorer</category><category domain="http://blogs.msdn.com/petel/archive/tags/IE8/default.aspx">IE8</category></item><item><title>ReMIX: Presentations in PDF &amp; Source for VS2008 Demo</title><link>http://blogs.msdn.com/petel/archive/2007/06/27/remix-presentations-in-pdf-source-for-vs2008-demo.aspx</link><pubDate>Thu, 28 Jun 2007 02:02:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:3572097</guid><dc:creator>PeteL</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/petel/comments/3572097.aspx</comments><wfw:commentRss>http://blogs.msdn.com/petel/commentrss.aspx?PostID=3572097</wfw:commentRss><description>&lt;p&gt;Yep, the internet is on!&amp;nbsp; I think most of the comments I got yesterday all revolved around the fact that I posted all my presentations in PPTX format.&amp;nbsp; I work for Microsoft, and well, I use PowerPoint to create my presentations.&amp;nbsp; I figured most people, even if they didn't have PowerPoint on their machines would at least have the viewer so they could see the slides, but it sounds like quite a few people would rather have a PDF or some other format.&amp;nbsp; So, here you go!&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.nocommonground.com/blogSamples/TechEd%20-%20Web%20Blunders.pdf" mce_href="http://www.nocommonground.com/blogSamples/TechEd%20-%20Web%20Blunders.pdf"&gt;TechEd: Top 5 Web Blunders&lt;/a&gt;&lt;br&gt;&lt;a href="http://www.nocommonground.com/blogSamples/ReMIX07-BuildVideoSite.pdf" mce_href="http://www.nocommonground.com/blogSamples/ReMIX07-BuildVideoSite.pdf"&gt;ReMIX: Building Your Own Video Site&lt;/a&gt;&lt;br&gt;&lt;a href="http://www.nocommonground.com/blogSamples/ReMIX07-Implementing%20Rich%20UI.pdf" mce_href="http://www.nocommonground.com/blogSamples/ReMIX07-Implementing%20Rich%20UI.pdf"&gt;ReMIX: Implementing Rich UI&lt;/a&gt;&lt;br&gt;&lt;a href="http://www.nocommonground.com/blogSamples/ReMIX07-Using%20VS%20Orcas.pdf" mce_href="http://www.nocommonground.com/blogSamples/ReMIX07-Using%20VS%20Orcas.pdf"&gt;ReMIX: A Tour Around VS2008&lt;/a&gt;&lt;br&gt;&lt;a href="http://www.nocommonground.com/blogSamples/ReMIX07-SEO.pdf" mce_href="http://www.nocommonground.com/blogSamples/ReMIX07-SEO.pdf"&gt;ReMIX: Search Engine Optimization for Rich Media&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Note that these are stored on my personal website, so I can't guarantee how long they'll last as they're not on an official Microsoft server.&amp;nbsp;&lt;/p&gt;&lt;p&gt;I've also included with this post the source to the VS2008 demo that I did.&amp;nbsp; I had to swap the pictures out and replace them with corporate clip art, but the rest of the content is the same.&amp;nbsp; I included the source for what I started with, and the source that I finished with so that you can see where I started, and where I finished.&amp;nbsp; If you want to follow along, you can watch the original demo at the MIX site&lt;br&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=3572097" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/petel/attachment/3572097.ashx" length="1877160" type="application/x-zip-compressed" /><category domain="http://blogs.msdn.com/petel/archive/tags/Microsoft/default.aspx">Microsoft</category><category domain="http://blogs.msdn.com/petel/archive/tags/CSS+Examples/default.aspx">CSS Examples</category><category domain="http://blogs.msdn.com/petel/archive/tags/Code+Samples/default.aspx">Code Samples</category><category domain="http://blogs.msdn.com/petel/archive/tags/share/default.aspx">share</category><category domain="http://blogs.msdn.com/petel/archive/tags/web+design/default.aspx">web design</category><category domain="http://blogs.msdn.com/petel/archive/tags/Internet+Explorer/default.aspx">Internet Explorer</category><category domain="http://blogs.msdn.com/petel/archive/tags/presentations/default.aspx">presentations</category></item><item><title>ReMIX: Search Engine Optimization For Rich Internet Applications</title><link>http://blogs.msdn.com/petel/archive/2007/06/25/remix-search-engine-optimization-for-rich-internet-applications.aspx</link><pubDate>Tue, 26 Jun 2007 00:06:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:3528441</guid><dc:creator>PeteL</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/petel/comments/3528441.aspx</comments><wfw:commentRss>http://blogs.msdn.com/petel/commentrss.aspx?PostID=3528441</wfw:commentRss><description>&lt;p&gt;I think that this was my favorite session I did while doing all my ReMIX presentations.&amp;nbsp; It was the one I found most interesting, and most relevant to the work that I do, and see many web developers and designers doing every day.&lt;/p&gt;&lt;p&gt;I'm not sure if there is video for this session, but if it shows up, I'll be sure to link to it.&amp;nbsp; In the mean time, I've included the slides for you to check out, and I'll try to get a blog post out about in the next week or two summarizing the info in the deck.&amp;nbsp;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=3528441" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/petel/attachment/3528441.ashx" length="561488" type="application/vnd.openxmlformats-officedocument.pres" /><category domain="http://blogs.msdn.com/petel/archive/tags/Microsoft/default.aspx">Microsoft</category><category domain="http://blogs.msdn.com/petel/archive/tags/CSS+Examples/default.aspx">CSS Examples</category><category domain="http://blogs.msdn.com/petel/archive/tags/Code+Samples/default.aspx">Code Samples</category><category domain="http://blogs.msdn.com/petel/archive/tags/share/default.aspx">share</category><category domain="http://blogs.msdn.com/petel/archive/tags/conferences/default.aspx">conferences</category><category domain="http://blogs.msdn.com/petel/archive/tags/web+design/default.aspx">web design</category></item><item><title>ReMIX: Building Your Own Video Site</title><link>http://blogs.msdn.com/petel/archive/2007/06/25/remix-building-your-own-video-site.aspx</link><pubDate>Tue, 26 Jun 2007 00:01:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:3528357</guid><dc:creator>PeteL</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/petel/comments/3528357.aspx</comments><wfw:commentRss>http://blogs.msdn.com/petel/commentrss.aspx?PostID=3528357</wfw:commentRss><description>&lt;p&gt;In Amsterdam and Zurich, I presented a session called Building Your Own Video Site.&amp;nbsp; It was pretty cool, but sadly, the one hour we had to do the session, there was no real way to build the application up from scratch, so we just used a pre-built sample, and added some new UI and features to it.&amp;nbsp; &lt;/p&gt;&lt;p&gt;The site is available to play with today on the MIX07 servers at &lt;a href="http://mixer1004.mixsandbox.com/%20" mce_href="http://mixer1004.mixsandbox.com/ "&gt;http://mixer1004.mixsandbox.com&lt;/a&gt; and you can see the slides and get the entire video from the &lt;a href="http://sessions.visitmix.com/default.asp?event=1011&amp;amp;session=2012&amp;amp;pid=DEV13&amp;amp;disc=&amp;amp;id=1522&amp;amp;year=2007&amp;amp;search=DEV13" mce_href="http://sessions.visitmix.com/default.asp?event=1011&amp;amp;session=2012&amp;amp;pid=DEV13&amp;amp;disc=&amp;amp;id=1522&amp;amp;year=2007&amp;amp;search=DEV13"&gt;MIX07 site&lt;/a&gt;.&amp;nbsp; I would include the slides that I used here, but the PPTX is about 10megs, so I'd suggest getting it from the MIX07 site where there's a bigger pipe, and more edge servers.&lt;br&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=3528357" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/petel/archive/tags/Code+Samples/default.aspx">Code Samples</category><category domain="http://blogs.msdn.com/petel/archive/tags/share/default.aspx">share</category><category domain="http://blogs.msdn.com/petel/archive/tags/presentations/default.aspx">presentations</category></item><item><title>ReMIX: Using Visual Studio 2008, codenamed Orcas</title><link>http://blogs.msdn.com/petel/archive/2007/06/25/remix-using-visual-studio-2008-codenamed-orcas.aspx</link><pubDate>Mon, 25 Jun 2007 23:57:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:3528098</guid><dc:creator>PeteL</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/petel/comments/3528098.aspx</comments><wfw:commentRss>http://blogs.msdn.com/petel/commentrss.aspx?PostID=3528098</wfw:commentRss><description>&lt;p&gt;I presented this session both in Amsterdam and in Zürich, though I managed to lose my notes in Zürich and had do to a number of the demo's by the seat of my pants which was a bit of a challenge.&amp;nbsp; &lt;/p&gt;&lt;p&gt;In any event, it was based on a session by Omar Khan of the VWD team that he presented at MIX07, called "&lt;a href="http://sessions.visitmix.com/default.asp?event=1011&amp;amp;session=2012&amp;amp;pid=DEV14&amp;amp;disc=&amp;amp;id=1523&amp;amp;year=2007&amp;amp;search=DEV14" mce_href="http://sessions.visitmix.com/default.asp?event=1011&amp;amp;session=2012&amp;amp;pid=DEV14&amp;amp;disc=&amp;amp;id=1523&amp;amp;year=2007&amp;amp;search=DEV14"&gt;Using Visual Studio Codename Orcas to Design And Devloper Rich AJAX Enable Web Sites&lt;/a&gt;"&lt;br&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=3528098" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/petel/attachment/3528098.ashx" length="551859" type="application/vnd.openxmlformats-officedocument.pres" /><category domain="http://blogs.msdn.com/petel/archive/tags/Code+Samples/default.aspx">Code Samples</category><category domain="http://blogs.msdn.com/petel/archive/tags/share/default.aspx">share</category><category domain="http://blogs.msdn.com/petel/archive/tags/conferences/default.aspx">conferences</category></item><item><title>ReMIX: Implementing Rich UI For Web Applications</title><link>http://blogs.msdn.com/petel/archive/2007/06/25/remix-implementing-rich-ui-for-web-applications.aspx</link><pubDate>Mon, 25 Jun 2007 23:51:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:3527973</guid><dc:creator>PeteL</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/petel/comments/3527973.aspx</comments><wfw:commentRss>http://blogs.msdn.com/petel/commentrss.aspx?PostID=3527973</wfw:commentRss><description>&lt;p&gt;In Amsterdam at ReMIX, I presented "Implementing Rich UI for Web Applications" where I showed how to deliver richly interactive web experiences with animation, video and more using Silverlight and Expression.&lt;/p&gt;&lt;p&gt;It was based on a session from MIX07 by Joe Stegman titled "&lt;a href="http://sessions.visitmix.com/default.asp?event=1011&amp;amp;session=2012&amp;amp;pid=DEV11&amp;amp;disc=&amp;amp;id=1520&amp;amp;year=2007&amp;amp;search=DEV11" mce_href="http://sessions.visitmix.com/default.asp?event=1011&amp;amp;session=2012&amp;amp;pid=DEV11&amp;amp;disc=&amp;amp;id=1520&amp;amp;year=2007&amp;amp;search=DEV11"&gt;Building Rich Web Experiences using Silverlight and JavaScript for Developers&lt;/a&gt;" &amp;nbsp;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=3527973" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/petel/attachment/3527973.ashx" length="927886" type="application/vnd.openxmlformats-officedocument.pres" /><category domain="http://blogs.msdn.com/petel/archive/tags/Code+Samples/default.aspx">Code Samples</category><category domain="http://blogs.msdn.com/petel/archive/tags/share/default.aspx">share</category><category domain="http://blogs.msdn.com/petel/archive/tags/ie/default.aspx">ie</category><category domain="http://blogs.msdn.com/petel/archive/tags/conferences/default.aspx">conferences</category><category domain="http://blogs.msdn.com/petel/archive/tags/Internet+Explorer/default.aspx">Internet Explorer</category></item><item><title>Web Blunders: The Top 5 Biggest Mistakes On The Web</title><link>http://blogs.msdn.com/petel/archive/2007/06/25/web-blunders-the-top-5-biggest-mistakes-on-the-web.aspx</link><pubDate>Mon, 25 Jun 2007 23:45:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:3527824</guid><dc:creator>PeteL</dc:creator><slash:comments>5</slash:comments><comments>http://blogs.msdn.com/petel/comments/3527824.aspx</comments><wfw:commentRss>http://blogs.msdn.com/petel/commentrss.aspx?PostID=3527824</wfw:commentRss><description>&lt;p&gt;At TechEd this year, I presented a session where I presented my top five pet peeves on the web, the biggest and easiest problems to avoid on the web.&amp;nbsp; With how easy it is to share content on the web, I felt that these top five things were the best and easiest to get rid of.&lt;/p&gt;&lt;p&gt;In order, I felt they were:&lt;/p&gt;&lt;p&gt;5.&amp;nbsp; Unprofessional Site Design&lt;br&gt;4.&amp;nbsp; Lousy Content&lt;br&gt;3.&amp;nbsp; Poorly coded HTML/CSS/JavaScript&lt;br&gt;2.&amp;nbsp; Inappropriate use of Rich Content&lt;br&gt;1.&amp;nbsp; Not Being POSH&lt;/p&gt;&lt;p&gt;I've attached my slides below, so check them out, and let me know what your pet peeves are!&amp;nbsp;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=3527824" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/petel/attachment/3527824.ashx" length="88818" type="application/vnd.openxmlformats-officedocument.pres" /><category domain="http://blogs.msdn.com/petel/archive/tags/CSS+Examples/default.aspx">CSS Examples</category><category domain="http://blogs.msdn.com/petel/archive/tags/Code+Samples/default.aspx">Code Samples</category><category domain="http://blogs.msdn.com/petel/archive/tags/share/default.aspx">share</category><category domain="http://blogs.msdn.com/petel/archive/tags/ie/default.aspx">ie</category><category domain="http://blogs.msdn.com/petel/archive/tags/conferences/default.aspx">conferences</category><category domain="http://blogs.msdn.com/petel/archive/tags/web+design/default.aspx">web design</category><category domain="http://blogs.msdn.com/petel/archive/tags/Internet+Explorer+7/default.aspx">Internet Explorer 7</category><category domain="http://blogs.msdn.com/petel/archive/tags/presentations/default.aspx">presentations</category></item><item><title>Javascript Debugging In Visual Web Developer &amp;quot;Orcas&amp;quot;</title><link>http://blogs.msdn.com/petel/archive/2007/03/13/javascript-debugging-in-visual-web-developer-quot-orcas-quot.aspx</link><pubDate>Wed, 14 Mar 2007 04:20:27 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1877045</guid><dc:creator>PeteL</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/petel/comments/1877045.aspx</comments><wfw:commentRss>http://blogs.msdn.com/petel/commentrss.aspx?PostID=1877045</wfw:commentRss><description>&lt;p&gt;Up until now, we've never had a great set of JavaScript debugging tools, but "Orcas", the next version of Visual Studio will have some great new JavaScript debugging tools.&amp;nbsp; While Visual Web Developer "Orcas" hasn't shipped yet, there is a CTP available that you can download and install. &lt;/p&gt; &lt;p&gt;The VWD team (and my old team)&amp;nbsp;has posted on their blog a couple of blog posts about how to do JS debugging in VWD Orcas.&amp;nbsp; It's worth checking out.&lt;/p&gt; &lt;ul&gt; &lt;li&gt;Jscript Intellisense in Orcas: &lt;a href="http://blogs.msdn.com/webdevtools/archive/2007/03/02/jscript-intellisense-in-orcas.aspx"&gt;http://blogs.msdn.com/webdevtools/archive/2007/03/02/jscript-intellisense-in-orcas.aspx&lt;/a&gt;&lt;br&gt;&lt;/li&gt; &lt;li&gt;Jscript Intellisense in March CTP – Gotchas &amp;amp; Workarounds: &lt;a href="http://blogs.msdn.com/webdevtools/archive/2007/03/07/jscript-intellisense-march-ctp-gotchas-workarounds.aspx"&gt;http://blogs.msdn.com/webdevtools/archive/2007/03/07/jscript-intellisense-march-ctp-gotchas-workarounds.aspx&lt;/a&gt;&lt;br&gt;&lt;/li&gt; &lt;li&gt;Jscript Debugging in Visual Web Developer 2005: &lt;a href="http://blogs.msdn.com/webdevtools/archive/2007/03/08/jscript-debugging-in-visual-studio-2005.aspx"&gt;http://blogs.msdn.com/webdevtools/archive/2007/03/08/jscript-debugging-in-visual-studio-2005.aspx&lt;/a&gt;&lt;br&gt;&lt;/li&gt; &lt;li&gt;Jscript Debugging in Visual Web Developer Orcas: &lt;a href="http://blogs.msdn.com/webdevtools/archive/2007/03/09/jscript-debugging-in-visual-web-developer-orcas.aspx"&gt;http://blogs.msdn.com/webdevtools/archive/2007/03/09/jscript-debugging-in-visual-web-developer-orcas.aspx&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1877045" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/petel/archive/tags/Microsoft/default.aspx">Microsoft</category><category domain="http://blogs.msdn.com/petel/archive/tags/Code+Samples/default.aspx">Code Samples</category><category domain="http://blogs.msdn.com/petel/archive/tags/share/default.aspx">share</category><category domain="http://blogs.msdn.com/petel/archive/tags/Internet+Explorer/default.aspx">Internet Explorer</category></item><item><title>Generating OPML's with the RSS Platform</title><link>http://blogs.msdn.com/petel/archive/2007/02/16/generating-opml-s-with-the-rss-platform.aspx</link><pubDate>Sat, 17 Feb 2007 01:04:22 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1691651</guid><dc:creator>PeteL</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/petel/comments/1691651.aspx</comments><wfw:commentRss>http://blogs.msdn.com/petel/commentrss.aspx?PostID=1691651</wfw:commentRss><description>&lt;p&gt;Just before I headed up to Web Directions North, I wrote a little chunk of code to help me do a system back up.&amp;nbsp; Enough people at work have been losing data on their hard disks, so I decided I wasn't going to have that happen to me.&amp;nbsp; I picked up a NAS storage device, 2 500gig hard drives, and got it all set up at home.&amp;nbsp; It works quite nicely.&amp;nbsp; I set up SyncToy to back up all the data that I find important, and run daily or weekly.&amp;nbsp; &lt;/p&gt; &lt;p&gt;But one thing was not getting back up that I was a bit worried about.&amp;nbsp; My RSS feed list.&amp;nbsp; I couldn't find where the RSS platform stores the OPML list, or even if it does, so I figured, since it's an open platform, I'd just write a method that would create the OPML list for me!&amp;nbsp; Once I got the initial work done, it was really easy.&amp;nbsp; &lt;/p&gt; &lt;p&gt;So, I figured I'd share the code.&amp;nbsp; This code will return a string, that is the OPML list of all the feeds that you've subscribed to using the RSS Platform.&amp;nbsp; Sure you can just go into IE, and choose File/Export, but that's a manual process, I wanted something automatic.&lt;/p&gt;&lt;pre&gt;using System;
using System.IO;
using System.Collections.Generic;
using System.Text;
using Microsoft.Feeds.Interop;
using System.Collections.Specialized;

namespace BackupHelper
{
    class OPMLBuilder
    {
        public string Result
        {
            get
            {
                return sbResult.ToString();
            }
        }

        StringBuilder sbResult;

        public OPMLBuilder()
        {
            sbResult = new StringBuilder();
            sbResult.Append("&lt;opml version="\&amp;quot;1.1\&amp;quot;"&gt;\r\n &lt;head&gt;\r\n  \r\n \r\n \r\n");
            FeedsManager mgr = new FeedsManagerClass();
            IFeedFolder root = (IFeedFolder)mgr.RootFolder;
            BuildFeeds(root, 0);
            sbResult.Remove(sbResult.Length - 13, 13);
            sbResult.Append(" \r\n&lt;/opml&gt;\r\n");

        }
        public bool WriteOPML(string filename)
        {
            try
            {
                //Pass the filepath and filename to the StreamWriter Constructor
                StreamWriter sw = new StreamWriter(filename);

                //Write a line of text
                sw.WriteLine(sbResult.ToString());

                //Close the file
                sw.Close();
                return true;
            }
            catch (Exception ex)
            {
                return false;
            }
        }

        private void BuildFeeds(IFeedFolder parent, int n)
        {
            string spacing = new string(' ', n+1);
            if (n &amp;gt; 0)
            {
                sbResult.Append(spacing + "&lt;outline  ?\? + ?&amp;amp;?) parent.Name.Replace(?&amp;?, text='\""'&gt;\r\n");
            }

            foreach (IFeed feed in (IFeedsEnum)parent.Feeds)
            {
                sbResult.Append(spacing + " &lt;outline  ?&amp;amp;?) text='\""+' type='\"rss\"/' +?\? feed.Url xmlUrl='\""+' feed.Name.Replace(?&amp;?,&gt;\r\n");
            }

            foreach (IFeedFolder folder in (IFeedsEnum)parent.Subfolders)
                BuildFeeds(folder, n + 1);

            sbResult.Append(spacing + "&lt;/outline&gt;" + "\r\n");
        }
    }
}
&lt;/pre&gt;
&lt;p&gt;Hope some of you find that useful!&lt;/p&gt;
&lt;p&gt;Sorry it's taken so long to get it up, after getting back from Web Directions North, I seem to have gotten hit with some kind of cold/flu or something that has knocked my on my butt.&amp;nbsp; I've been at home all week.&amp;nbsp; I've done about 30 emails all week, and usually I'm about 50-80 a day!&amp;nbsp; If that gives you any idea of how I've been feeling.&amp;nbsp; Today is the first day I've felt somewhat human again.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1691651" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/petel/archive/tags/Microsoft/default.aspx">Microsoft</category><category domain="http://blogs.msdn.com/petel/archive/tags/Code+Samples/default.aspx">Code Samples</category><category domain="http://blogs.msdn.com/petel/archive/tags/share/default.aspx">share</category><category domain="http://blogs.msdn.com/petel/archive/tags/ie/default.aspx">ie</category><category domain="http://blogs.msdn.com/petel/archive/tags/Internet+Explorer/default.aspx">Internet Explorer</category><category domain="http://blogs.msdn.com/petel/archive/tags/Internet+Explorer+7/default.aspx">Internet Explorer 7</category><category domain="http://blogs.msdn.com/petel/archive/tags/RSS/default.aspx">RSS</category></item><item><title>Web Design World Session: IE7 From CSS to RSS: How to Take Full Advantage</title><link>http://blogs.msdn.com/petel/archive/2006/12/13/web-design-world-session-ie7-from-css-to-rss-how-to-take-full-advantage.aspx</link><pubDate>Wed, 13 Dec 2006 23:51:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1277486</guid><dc:creator>PeteL</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/petel/comments/1277486.aspx</comments><wfw:commentRss>http://blogs.msdn.com/petel/commentrss.aspx?PostID=1277486</wfw:commentRss><description>&lt;P&gt;I just finished my session titled "Internet Explorer 7 From CSS to RSS: How To Take Full Advantage" here at Web Design World, and it went over pretty well.&amp;nbsp; Cameron Moll is currently doing a session right now, so we did lose quite a few people to him, but he's an excellent speaker and is showing some really cool CSS and design stuff, so I understand why they're over there.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;I talked about some of the cool features around IE7, like what quirks mode is vs. standards mode; how to use RSS on your site, how to implement OpenSearch on your page, and then finally some of the cool CSS fixes that we made for IE7.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;I've uploaded my slides along with this post so that the info can be shared.&amp;nbsp; I'm don't have the samples that I showed available, but much of the info that I showed is included in the slides.&amp;nbsp; If you're looking for something specific, let me know and I'll try to get it up there for you!&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1277486" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/petel/attachment/1277486.ashx" length="889344" type="application/vnd.ms-powerpoint" /><category domain="http://blogs.msdn.com/petel/archive/tags/CSS+Examples/default.aspx">CSS Examples</category><category domain="http://blogs.msdn.com/petel/archive/tags/Code+Samples/default.aspx">Code Samples</category><category domain="http://blogs.msdn.com/petel/archive/tags/share/default.aspx">share</category><category domain="http://blogs.msdn.com/petel/archive/tags/ie/default.aspx">ie</category><category domain="http://blogs.msdn.com/petel/archive/tags/web+design/default.aspx">web design</category><category domain="http://blogs.msdn.com/petel/archive/tags/Internet+Explorer/default.aspx">Internet Explorer</category><category domain="http://blogs.msdn.com/petel/archive/tags/Internet+Explorer+7/default.aspx">Internet Explorer 7</category><category domain="http://blogs.msdn.com/petel/archive/tags/RSS/default.aspx">RSS</category><category domain="http://blogs.msdn.com/petel/archive/tags/presentations/default.aspx">presentations</category></item><item><title>Random Image Loading With JavaScript</title><link>http://blogs.msdn.com/petel/archive/2006/11/18/random-image-loading-with-javascript.aspx</link><pubDate>Sun, 19 Nov 2006 03:52:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1101369</guid><dc:creator>PeteL</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/petel/comments/1101369.aspx</comments><wfw:commentRss>http://blogs.msdn.com/petel/commentrss.aspx?PostID=1101369</wfw:commentRss><description>&lt;P&gt;I'm teaching the &lt;A class="" href="http://www.pcnw.org/school/workshops.php#updatingweb" target=_blank mce_href="http://www.pcnw.org/school/workshops.php#updatingweb"&gt;From Prints To Online: Updating Your Website&lt;/A&gt; class today at PCNW, and I had someone ask how they could random show an image on their home page.&amp;nbsp; All of the students aren't really web designer or developers, but fine art photographers.&amp;nbsp; They know and understand photography like the back of their hands, but not HTML, CSS or JavaScript.&lt;/P&gt;
&lt;P&gt;Normally with a big class, I would have said it's a little too hard to teach to all 12 students (remember, these are not people who understand code).&amp;nbsp; But, I've got a small class this weekend, so I figured why not.&amp;nbsp; I also figured I might as well post it for those who are interested.&lt;/P&gt;
&lt;P&gt;In the head, you'll need to paste the following code:&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#000080&gt;&amp;lt;script type="text/javascript" language="JavaScript"&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; MyImages=new Array();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; MyImages[0]='034.jpg';&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; MyImages[1]='038.jpg';&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; MyImages[2]='acid2.jpg';&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; MyImages[3]='boat.jpg'; &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#000080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; function newImage() &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; document.getElementById("mainImage").setAttribute("src", MyImages[Math.round(Math.random()*3)])&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&amp;lt;/script&amp;gt;&lt;/FONT&gt; 
&lt;P&gt;You'll obviously need to change the file names to what ever files you want to load. 
&lt;P&gt;In the &amp;lt;body&amp;gt; tag, you'll also need to add onload="newImage()", so you get something like &lt;FONT color=#000080&gt;&amp;lt;body onload="newImage()"&amp;gt;&lt;/FONT&gt; 
&lt;P&gt;Finally, you need to make sure that you have an image with an ID of "mainImage" on your page somewhere.&amp;nbsp; If you don't, you'll get JavaScript errors. 
&lt;P&gt;&lt;FONT color=#000080&gt;&amp;lt;img id="mainImage" /&amp;gt;&lt;/FONT&gt; 
&lt;P&gt;Hope this helps!&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1101369" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/petel/archive/tags/Microsoft/default.aspx">Microsoft</category><category domain="http://blogs.msdn.com/petel/archive/tags/Code+Samples/default.aspx">Code Samples</category><category domain="http://blogs.msdn.com/petel/archive/tags/share/default.aspx">share</category><category domain="http://blogs.msdn.com/petel/archive/tags/ie/default.aspx">ie</category><category domain="http://blogs.msdn.com/petel/archive/tags/web+design/default.aspx">web design</category><category domain="http://blogs.msdn.com/petel/archive/tags/Internet+Explorer/default.aspx">Internet Explorer</category><category domain="http://blogs.msdn.com/petel/archive/tags/Internet+Explorer+7/default.aspx">Internet Explorer 7</category></item><item><title>Live From Redmond: Creating Real World Web Application UI with Master Pages, Themes and Site Navigation</title><link>http://blogs.msdn.com/petel/archive/2006/08/07/691652.aspx</link><pubDate>Tue, 08 Aug 2006 04:08:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:691652</guid><dc:creator>PeteL</dc:creator><slash:comments>9</slash:comments><comments>http://blogs.msdn.com/petel/comments/691652.aspx</comments><wfw:commentRss>http://blogs.msdn.com/petel/commentrss.aspx?PostID=691652</wfw:commentRss><description>&lt;P&gt;A few days ago, I presented a &lt;A href="http://www.microsoft.com/events/EventDetails.aspx?CMTYSvcSource=MSCOMMedia&amp;amp;Params=%7eCMTYDataSvcParams%5e%7earg+Name%3d%22ID%22+Value%3d%221032303787%22%2f%5e%7earg+Name%3d%22ProviderID%22+Value%3d%22A6B43178-497C-4225-BA42-DF595171F04C%22%2f%5e%7earg+Name%3d%22lang%22+Value%3d%22en%22%2f%5e%7earg+Name%3d%22cr%22+Value%3d%22US%22%2f%5e%7esParams%5e%7e%2fsParams%5e%7e%2fCMTYDataSvcParams%5e"&gt;Live From Redmond: Creating Real World Web Application UI with Master Pages, Themes and Site Navigation&lt;/A&gt; in an on demand web cast.&amp;nbsp; For my first presentation, it went pretty well.&amp;nbsp; I had never used Live Meeting before, and had only had one Live Meeting "Goofup", where I forgot to shift over to the desktop, instead of the slides.&lt;/P&gt;
&lt;P&gt;The presentation went well, but admittedly, there was a lot of information presented, an hour was really way too short to do everything that I wanted to talk about.&amp;nbsp; In fact, I cut out a good chunk of stuff as I was moving through in order to get through to site navigation and themes in the last few minutes.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;In any event, I had said that I would offer the sample for download after the presentation, and so here it is. You can download it at &lt;A href="http://www.nocommonground.com/blogSamples/finishedsite.zip"&gt;http://www.nocommonground.com/blogSamples/finishedsite.zip&lt;/A&gt;. It's about 6 megs to download but contains everything that I demo'ed in it's completed form, so you can use that as a sample for where you want to go.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=691652" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/petel/archive/tags/CSS+Examples/default.aspx">CSS Examples</category><category domain="http://blogs.msdn.com/petel/archive/tags/Code+Samples/default.aspx">Code Samples</category><category domain="http://blogs.msdn.com/petel/archive/tags/share/default.aspx">share</category></item><item><title>File Checksum</title><link>http://blogs.msdn.com/petel/archive/2006/04/06/570502.aspx</link><pubDate>Fri, 07 Apr 2006 05:37:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:570502</guid><dc:creator>PeteL</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/petel/comments/570502.aspx</comments><wfw:commentRss>http://blogs.msdn.com/petel/commentrss.aspx?PostID=570502</wfw:commentRss><description>&lt;P&gt;I brought a neat idea to my lead earlier this week, and lo and behold, he started working on it!&amp;nbsp; He got the hard part done one morning when he was in before everyone else, but now I get to implement this idea.&lt;/P&gt;
&lt;P&gt;With the new designer&amp;nbsp;surface, I wanted to create a test bed that used a known set of HTML and ASPX files and checked their design time rendering.&amp;nbsp; The idea being that we'd have a set of "golden" images, and would run our test bed against these golden images.&amp;nbsp; If anything changed, we'd fail that test and could look at the image to find out what had changed in the rendering and figure out if its a bug or an actual planned change.&amp;nbsp; I've got a collection of about 600+ web sites, and I wanted this test to be pretty dynamic, so adding new tests took next to no work, or pulling them out was next to no work.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;John got the first part done this week, the designer surface image capture, and he also created an image comparer.&amp;nbsp; It looks at the two bitmaps, and compares them pixel by pixel.&amp;nbsp; If they're different, it creates a new file with the different pixels highlighed in lime green.&amp;nbsp; As I was working on it today, I decided that I don't want to compare every pixel, as more often than not, the pixels will be the same, so instead, I wanted to find a way to create a checksum of the file, and only compare if the check sums are different. I did a bit of searching online, and came up with the following code.&lt;/P&gt;
&lt;P&gt;&lt;PRE&gt;    Function GetChecksum(ByVal file As String) As Byte()
        Dim md5 As New System.Security.Cryptography.MD5CryptoServiceProvider()
        Using fStream As New System.IO.FileStream(file, IO.FileMode.Open)
            Dim bytes() As Byte = md5.ComputeHash(fStream)
            fStream.Close()
            Return bytes
        End Using
    End Function

    Function ToHexString(ByVal bytes() As Byte) As String
        Dim hexStr As New System.Text.StringBuilder()
        Dim i As Integer
        For i = 0 To bytes.Length - 1
            hexStr.Append(Hex(bytes(i)))
        Next i
        Return hexStr.ToString()
    End Function
&lt;/PRE&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Super Sweet! You feed in the file and it feeds out an array of bytes.&amp;nbsp; For ease of comparison and human reading, I'm having the tool convert the bytes to hex so that I've got something that I can see and compare.&lt;/P&gt;
&lt;P&gt;This thing saved me about 8 minutes for only 6 sites.&amp;nbsp; I went from comparing 6 sites in about 10 minutes to 6 sites in less than 2 minutes!&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=570502" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/petel/archive/tags/Microsoft/default.aspx">Microsoft</category><category domain="http://blogs.msdn.com/petel/archive/tags/Code+Samples/default.aspx">Code Samples</category><category domain="http://blogs.msdn.com/petel/archive/tags/share/default.aspx">share</category></item><item><title>There's A Hard Way &amp; An Easy Way: Getting/Reading HTTP Responses</title><link>http://blogs.msdn.com/petel/archive/2006/03/03/543009.aspx</link><pubDate>Fri, 03 Mar 2006 20:08:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:543009</guid><dc:creator>PeteL</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/petel/comments/543009.aspx</comments><wfw:commentRss>http://blogs.msdn.com/petel/commentrss.aspx?PostID=543009</wfw:commentRss><description>&lt;P&gt;Yesterday, after somone asked on the forums how to do a web request in an application, I posted some code that I had written a while ago, and I got some great feedback on it.&amp;nbsp; It solved a problem that I was working on, and did exactly what a few people have been asking for.&lt;/P&gt;
&lt;P&gt;As it turns out, that was the hard way of doing things.&amp;nbsp; If you don't count { } on separate lines, that took 9 lines of code.&amp;nbsp; Someone yesterday pointed out how to do it in 4.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;So I present to you, 4 lines:&lt;/P&gt;
&lt;DIV style="FONT-SIZE: 9pt; FONT-FAMILY: monospace; BACKGROUND-COLOR: white"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=blue&gt;public&lt;/FONT&gt;&lt;FONT color=black&gt; &lt;/FONT&gt;&lt;FONT color=blue&gt;static&lt;/FONT&gt;&lt;FONT color=black&gt; &lt;/FONT&gt;&lt;FONT color=blue&gt;string&lt;/FONT&gt;&lt;FONT color=black&gt; GetHTML(&lt;/FONT&gt;&lt;FONT color=blue&gt;string&lt;/FONT&gt;&lt;FONT color=black&gt; url, &lt;/FONT&gt;&lt;FONT color=blue&gt;string&lt;/FONT&gt;&lt;FONT color=black&gt; proxy)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;System.Net.&lt;/FONT&gt;&lt;FONT color=teal&gt;WebClient&lt;/FONT&gt;&lt;FONT color=black&gt; client = &lt;/FONT&gt;&lt;FONT color=blue&gt;new&lt;/FONT&gt;&lt;FONT color=black&gt; &lt;/FONT&gt;&lt;FONT color=teal&gt;WebClient&lt;/FONT&gt;&lt;FONT color=black&gt;();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=blue&gt;if&lt;/FONT&gt;&lt;FONT color=black&gt; (!&lt;/FONT&gt;&lt;FONT color=teal&gt;String&lt;/FONT&gt;&lt;FONT color=black&gt;.IsNullOrEmpty(proxy))&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;client.Proxy = proxy;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=blue&gt;return&lt;/FONT&gt;&lt;FONT color=black&gt; client.DownloadString(&lt;/FONT&gt;&lt;FONT color=blue&gt;new&lt;/FONT&gt;&lt;FONT color=black&gt; &lt;/FONT&gt;&lt;FONT color=teal&gt;Uri&lt;/FONT&gt;&lt;FONT color=black&gt;(&lt;/FONT&gt;url&lt;FONT color=black&gt;));&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/FONT&gt; &lt;/DIV&gt;
&lt;P&gt;The one difference on this, it that in the one from yesterday, I was able to put a timeout of 2.5 seconds.&amp;nbsp; If the page hadn't downloaded in that, it failed.&amp;nbsp; With the code I've posted today, there doesn't seem to be a method or property to set that value.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=543009" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/petel/archive/tags/Microsoft/default.aspx">Microsoft</category><category domain="http://blogs.msdn.com/petel/archive/tags/Code+Samples/default.aspx">Code Samples</category></item><item><title>Getting/Reading HTTP Responses</title><link>http://blogs.msdn.com/petel/archive/2006/03/02/542228.aspx</link><pubDate>Thu, 02 Mar 2006 20:16:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:542228</guid><dc:creator>PeteL</dc:creator><slash:comments>6</slash:comments><comments>http://blogs.msdn.com/petel/comments/542228.aspx</comments><wfw:commentRss>http://blogs.msdn.com/petel/commentrss.aspx?PostID=542228</wfw:commentRss><description>&lt;P&gt;There has been a semi-frequent request on forums and such for people who want to do an HTTP request from their application (either web or client) and get the response as a string back so that they can process it from there.&amp;nbsp; I had some code that did something similar, so I figured I'd modify it and post it here for all to use.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;This will work in any application, either Windows Client, or as part of a Web Application (if you wanted to create a magic proxy site).&amp;nbsp; &lt;/P&gt;
&lt;DIV style="FONT-SIZE: 9pt; FONT-FAMILY: monospace; BACKGROUND-COLOR: white"&gt;&lt;FONT color=blue&gt;using&lt;/FONT&gt;&lt;FONT color=black&gt; System;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=blue&gt;using&lt;/FONT&gt;&lt;FONT color=black&gt; System.IO;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=blue&gt;using&lt;/FONT&gt;&lt;FONT color=black&gt; System.Net;&lt;BR&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=blue&gt;namespace&lt;/FONT&gt;&lt;FONT color=black&gt; HTTPReader&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=blue&gt;class&lt;/FONT&gt;&lt;FONT color=black&gt; &lt;/FONT&gt;&lt;FONT color=teal&gt;HTTPReader&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=black&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=blue&gt;public&lt;/FONT&gt;&lt;FONT color=black&gt; &lt;/FONT&gt;&lt;FONT color=blue&gt;static&lt;/FONT&gt;&lt;FONT color=black&gt; &lt;/FONT&gt;&lt;FONT color=blue&gt;string&lt;/FONT&gt;&lt;FONT color=black&gt; GetHTML(&lt;/FONT&gt;&lt;FONT color=blue&gt;string&lt;/FONT&gt;&lt;FONT color=black&gt; url, &lt;/FONT&gt;&lt;FONT color=blue&gt;string&lt;/FONT&gt;&lt;FONT color=black&gt; proxy)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;System.Net.&lt;/FONT&gt;&lt;FONT color=teal&gt;WebRequest&lt;/FONT&gt;&lt;FONT color=black&gt; wr = System.Net.&lt;/FONT&gt;&lt;FONT color=teal&gt;WebRequest&lt;/FONT&gt;&lt;FONT color=black&gt;.Create(url);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;wr.Timeout = 2500; &lt;/FONT&gt;&lt;FONT color=green&gt;// 2.5 seconds&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=black&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=blue&gt;if&lt;/FONT&gt;&lt;FONT color=black&gt; (!&lt;/FONT&gt;&lt;FONT color=teal&gt;String&lt;/FONT&gt;&lt;FONT color=black&gt;.IsNullOrEmpty(proxy))&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;System.Net.&lt;/FONT&gt;&lt;FONT color=teal&gt;WebProxy&lt;/FONT&gt;&lt;FONT color=black&gt; myProxy = &lt;/FONT&gt;&lt;FONT color=blue&gt;new&lt;/FONT&gt;&lt;FONT color=black&gt; System.Net.&lt;/FONT&gt;&lt;FONT color=teal&gt;WebProxy&lt;/FONT&gt;&lt;FONT color=black&gt;(proxy, &lt;/FONT&gt;&lt;FONT color=blue&gt;true&lt;/FONT&gt;&lt;FONT color=black&gt;);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;wr.Proxy = myProxy;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=blue&gt;using&lt;/FONT&gt;&lt;FONT color=black&gt; (System.Net.&lt;/FONT&gt;&lt;FONT color=teal&gt;WebResponse&lt;/FONT&gt;&lt;FONT color=black&gt; wresp = wr.GetResponse())&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=teal&gt;Stream&lt;/FONT&gt;&lt;FONT color=black&gt; s = wresp.GetResponseStream();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=blue&gt;using&lt;/FONT&gt;&lt;FONT color=black&gt; (&lt;/FONT&gt;&lt;FONT color=teal&gt;StreamReader&lt;/FONT&gt;&lt;FONT color=black&gt; sr = &lt;/FONT&gt;&lt;FONT color=blue&gt;new&lt;/FONT&gt;&lt;FONT color=black&gt; &lt;/FONT&gt;&lt;FONT color=teal&gt;StreamReader&lt;/FONT&gt;&lt;FONT color=black&gt;(s))&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=blue&gt;return&lt;/FONT&gt;&lt;FONT color=black&gt; sr.ReadToEnd();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;}&lt;BR&gt;&lt;/FONT&gt;&lt;/DIV&gt;
&lt;P&gt;&lt;STRONG&gt;Edit1: &lt;/STRONG&gt;You know, one thing I love about the community, you tell me when I'm wrong, or can do things better.&amp;nbsp; This is slightly updated after poppyto provided a few suggestions!&amp;nbsp; Thanks!&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Edit2: &lt;/STRONG&gt;Thanks to toub, I've added his suggested changes.&amp;nbsp; It's fair to note, that I'm not catching any exceptions in here, and that is intentional.&amp;nbsp; You could wrap this in a try catch block, but I'd rather you handle this how you want your app to deal with it.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=542228" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/petel/archive/tags/Microsoft/default.aspx">Microsoft</category><category domain="http://blogs.msdn.com/petel/archive/tags/Code+Samples/default.aspx">Code Samples</category></item></channel></rss>