<?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>Charlie Calvert's Community Blog : Web</title><link>http://blogs.msdn.com/charlie/archive/tags/Web/default.aspx</link><description>Tags: Web</description><dc:language>en</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Webcast: Lighting Up the New Visual Studio 2010 Editor with Rich Extensions (Level 200)</title><link>http://blogs.msdn.com/charlie/archive/2009/12/08/webcast-lighting-up-the-new-visual-studio-2010-editor-with-rich-extensions-level-200.aspx</link><pubDate>Tue, 08 Dec 2009 19:02:47 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9934214</guid><dc:creator>Charlie Calvert</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/charlie/comments/9934214.aspx</comments><wfw:commentRss>http://blogs.msdn.com/charlie/commentrss.aspx?PostID=9934214</wfw:commentRss><description>&lt;p&gt;Microsoft Events on MSDN will be hosting a &lt;a href="http://msevents.microsoft.com/CUI/WebCastEventDetails.aspx?EventID=1032434989&amp;amp;EventCategory=4&amp;amp;culture=en-US&amp;amp;CountryCode=US"&gt;webcast&lt;/a&gt; on Wednesday, December 09, 2009 10:00 AM Pacific Time. The event is designed to familiarize you with the new editor extensions that the WPF redesign have helped make possible. You can find more &lt;a href="http://www.microsoft.com/events/series/msdnvs2008.aspx?tab=webcasts"&gt;webcasts&lt;/a&gt;, &lt;a href="http://www.microsoft.com/events/series/msdnvs2008.aspx?tab=videos"&gt;videos&lt;/a&gt;, &lt;a href="http://www.microsoft.com/events/series/msdnvs2008.aspx?tab=virtuallabs"&gt;virtual labs&lt;/a&gt; and &lt;a href="http://www.microsoft.com/events/series/msdnvs2008.aspx?tab=podcasts&amp;amp;pageId=x1429&amp;amp;seriesID=Series-9879bbd7-b9f0-42e7-b599-ccb6f4bfe0d6.xml"&gt;podcasts&lt;/a&gt; by following this &lt;a href="http://www.microsoft.com/events/series/msdnvs2008.aspx"&gt;link&lt;/a&gt;.&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://www.microsoft.com/events/series/msdnvs2008.aspx?tab=podcasts&amp;amp;pageId=x1429&amp;amp;seriesID=Series-9879bbd7-b9f0-42e7-b599-ccb6f4bfe0d6.xml"&gt;Podcasts&lt;/a&gt;       &lt;ul&gt;       &lt;li&gt;RSS for &lt;a href="http://www.microsoft.com/events/podcasts/default.aspx?pageID=x73&amp;amp;podcast=rss&amp;amp;mode=mp3&amp;amp;seriesID=Series-9879bbd7-b9f0-42e7-b599-ccb6f4bfe0d6.xml&amp;amp;category="&gt;Microsoft Podcasts about Visual Studio 2008: Develop at Light Speed on the Latest Platforms&lt;/a&gt; (MP3) &lt;/li&gt;        &lt;li&gt;RSS for &lt;a href="http://www.microsoft.com/events/podcasts/default.aspx?pageID=x73&amp;amp;podcast=rss&amp;amp;mode=wma&amp;amp;seriesID=Series-9879bbd7-b9f0-42e7-b599-ccb6f4bfe0d6.xml&amp;amp;category="&gt;Microsoft Podcasts about Visual Studio 2008: Develop at Light Speed on the Latest Platforms&lt;/a&gt; (WMA) &lt;/li&gt;     &lt;/ul&gt;   &lt;/li&gt;    &lt;li&gt;&lt;a href="http://www.microsoft.com/events/series/msdnvs2008.aspx?tab=videos"&gt;Visual Studio 2008 Videos&lt;/a&gt;       &lt;ul&gt;       &lt;li&gt;&lt;a href="http://www.microsoft.com/events/series/msdnvs2008.aspx?tab=rss"&gt;RSS Feed for videos and webcasts&lt;/a&gt; &lt;/li&gt;     &lt;/ul&gt;   &lt;/li&gt;    &lt;li&gt;&lt;a href="http://www.microsoft.com/events/series/msdnvs2008.aspx?tab=webcasts"&gt;Webcasts&lt;/a&gt;       &lt;ul&gt;       &lt;li&gt;&lt;a href="http://www.microsoft.com/events/series/msdnvs2008.aspx?tab=rss"&gt;RSS Feed for videos and webcasts&lt;/a&gt; &lt;/li&gt;     &lt;/ul&gt;   &lt;/li&gt;    &lt;li&gt;&lt;a href="http://www.microsoft.com/events/series/msdnvs2008.aspx?tab=virtuallabs"&gt;Virtual Labs&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt; &lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fblogs.msdn.com%2fcharlie%2farchive%2f2009%2f12%2f08%2fwebcast-lighting-up-the-new-visual-studio-2010-editor-with-rich-extensions-level-200.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fblogs.msdn.com%2fcharlie%2farchive%2f2009%2f12%2f08%2fwebcast-lighting-up-the-new-visual-studio-2010-editor-with-rich-extensions-level-200.aspx" /&gt;&lt;/a&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9934214" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/charlie/archive/tags/CSharp/default.aspx">CSharp</category><category domain="http://blogs.msdn.com/charlie/archive/tags/Visual+Studio/default.aspx">Visual Studio</category><category domain="http://blogs.msdn.com/charlie/archive/tags/Games/default.aspx">Games</category><category domain="http://blogs.msdn.com/charlie/archive/tags/Web/default.aspx">Web</category></item><item><title>CSharp “How Do I Videos (Podcasts)” for the Zune Software</title><link>http://blogs.msdn.com/charlie/archive/2009/11/01/csharp-how-do-i-videos-for-the-zune-software.aspx</link><pubDate>Sun, 01 Nov 2009 20:54:40 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9915933</guid><dc:creator>Charlie Calvert</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/charlie/comments/9915933.aspx</comments><wfw:commentRss>http://blogs.msdn.com/charlie/commentrss.aspx?PostID=9915933</wfw:commentRss><description>&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;p&gt;It can be handy to create custom RSS feeds for the Zune so that it is easy to download and watch selected videos. You can watch these videos either on your PC, or on the Zune itself. &lt;a href="http://www.elvenware.com/charlie/rss/CSharpZuneReadyHowDoIVideos.rss"&gt;Here&lt;/a&gt; is a custom feed I created that contains all the new C# 4.0 language and IDE &lt;a href="http://msdn.microsoft.com/en-us/bb629407.aspx"&gt;How Do I Videos&lt;/a&gt;, plus a selection of other How Do I videos. In total, at this time, there are 35 videos in the feed. The RSS I created uses a simple and quite minimal syntax tested only with Internet Explorer 8 and the software for Zune 4.0.740.0. The source for the C# program that generated the feed includes regular expressions, LINQ to Objects and LINQ to SQL. I discuss that program briefly at the bottom of this post.&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://www.elvenware.com/charlie/rss/CSharpZuneReadyHowDoIVideos.rss"&gt;Charlie’s Custom C# and Visual Studio Feed&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/bb629407.aspx"&gt;The How Do I Video Home Page with over 500 Videos&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;How Do Videos for &lt;a href="http://msdn.microsoft.com/en-us/vstudio/bb507746.aspx"&gt;Visual Studio&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/vcsharp/bb798022.aspx"&gt;How Do I Videos for C#&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;Download the &lt;a href="http://code.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=linqfarm&amp;amp;DownloadId=7971"&gt;source&lt;/a&gt; for this post from the &lt;a href="http://code.msdn.microsoft.com/linqfarm"&gt;LINQ farm&lt;/a&gt;. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;You can use this custom feed from inside IE, as shown in Figure 0. However, I really created this feed to run on the Zune, so you should import the feed into the Zune software as a series of podcast. I explain this latter process in the next section of this post.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/charlie/WindowsLiveWriter/CSharpHowDoIVideosfortheZuneSoftware_AB92/Figure00_2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Figure00" border="0" alt="Figure00" src="http://blogs.msdn.com/blogfiles/charlie/WindowsLiveWriter/CSharpHowDoIVideosfortheZuneSoftware_AB92/Figure00_thumb.png" width="644" height="471" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Figure 0: Viewing a simple RSS feed in IE 8. Click the image to expand it.&lt;/strong&gt;&lt;/p&gt;  &lt;h2&gt;Using the Feed in the Zune Software&lt;/h2&gt;  &lt;p&gt;In this section I provide a quick tutorial for those who’ve never used Podcasts with a Zune. Open &lt;a href="http://www.elvenware.com/charlie/rss/CSharpZuneReadyHowDoIVideos.rss"&gt;the custom RSS&lt;/a&gt; feed in IE and grab the URL from the address bar. Alternately, you can just right click on any of the links to the feed in this document and choose &lt;strong&gt;Copy Shortcut &lt;/strong&gt;or whatever the equivalent command is in Firefox or other browsers. Open the Zune software and turn to the &lt;strong&gt;Collection | Podcasts&lt;/strong&gt; page. Click the button on the bottom left of the page called &lt;strong&gt;Add a Podcast&lt;/strong&gt;. The &lt;strong&gt;Subscribe&lt;/strong&gt; dialog appears. Paste in the URL for the feed, as shown in Figure 1, and then click the &lt;strong&gt;Subscribe&lt;/strong&gt; button. The various How Do I podcasts included in the feed should begin downloading to your system, as shown in Figure 2.&lt;/p&gt;  &lt;p&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Figure01" border="0" alt="Figure01" src="http://blogs.msdn.com/blogfiles/charlie/WindowsLiveWriter/CSharpHowDoIVideosfortheZuneSoftware_AB92/Figure01_3.png" width="471" height="223" /&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Figure 1: Subscribing to an RSS Podcast feed in Zune Software 4.0.740.0&lt;/strong&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/charlie/WindowsLiveWriter/CSharpHowDoIVideosfortheZuneSoftware_AB92/Figure02_2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Figure02" border="0" alt="Figure02" src="http://blogs.msdn.com/blogfiles/charlie/WindowsLiveWriter/CSharpHowDoIVideosfortheZuneSoftware_AB92/Figure02_thumb.png" width="644" height="317" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Figure 2: Viewing a feed in the Zune Software.&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;You can then plug in your Zune and right click on the feed and choose to sync the videos to your device. I’ll confess, however, that many of these videos look best on a PC, since you need a certain amount of screen real estate to adequately view the code typed in by the presenters. &lt;/p&gt;  &lt;h2&gt;&lt;strong&gt;Creating the RSS Feed by Screen Scrapping&lt;/strong&gt;&lt;/h2&gt;  &lt;p&gt;I created this feed by the time honored hack of screen scraping. I first copied the URL for the home page of each video and passed it to C# code designed to download the HTML associated with the URL. The program parsed the HTML looking for the elements I needed in my feed. LINQ to XML provided a handy tool for creating my simple RSS feed. I simply passed in the data retrieved from the HTML file to a set of LINQ routines designed to produce the XML for an RSS feed. &lt;/p&gt;  &lt;p&gt;This technique is simple to implement.&amp;#160; Screen scraping is nevertheless a very brittle practice, as my code will last only so long as the basic structure of the HTML pages that I’m parsing remains static. How long such conditions will prevail one can only suppose.&lt;/p&gt;  &lt;p&gt;I called my quick and dirty program &lt;strong&gt;CreateRssFeed, &lt;/strong&gt;and its source is available for &lt;a href="http://code.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=linqfarm&amp;amp;DownloadId=7971"&gt;download&lt;/a&gt;. The program is based on two custom classes, one for generating the RSS feed, the other for using Regular Expressions to parse the HTML file.&amp;#160; I store the URLs for the 35 HDI video pages in a file called &lt;strong&gt;UrlsToProcess.txt&lt;/strong&gt;. I won’t bore you with the complete listings for this code, but I show the main body in Listing 1, and a short excerpt from the RSS feed is shown in Listing 2. &lt;/p&gt;  &lt;p&gt;When you download the source, you will find versions for both VS 2008 and VS 2010, Beta 2. The latter solution contains both a console and a windows forms app. They each have their advantages, but I tend to prefer the former.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Listing 1: The main body of the program.&lt;/strong&gt;&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:86edbd1a-51cc-4e41-8c27-625eb52e991e" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt; &lt;div style="background: #ddd; max-height: 300px; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;using&lt;/span&gt; System;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#0000ff"&gt;using&lt;/span&gt; System.Collections.Generic;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;using&lt;/span&gt; System.IO;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#0000ff"&gt;using&lt;/span&gt; CreateRssVideo.Code;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#0000ff"&gt;namespace&lt;/span&gt; CreateRssVideo&lt;/li&gt; &lt;li&gt;{&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af"&gt;ProgramConsole&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;{&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff"&gt;void&lt;/span&gt; Main(&lt;span style="color:#0000ff"&gt;string&lt;/span&gt;[] args)&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;{&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;string&lt;/span&gt;[] urls = &lt;span style="color:#2b91af"&gt;File&lt;/span&gt;.ReadAllLines(&lt;span style="color:#a31515"&gt;&amp;quot;UrlsToProcess.txt&amp;quot;&lt;/span&gt;);&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#2b91af"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color:#0000ff"&gt;string&lt;/span&gt;&amp;gt; items = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color:#0000ff"&gt;string&lt;/span&gt;&amp;gt;();&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#2b91af"&gt;ParseHdiVideoPages&lt;/span&gt; parser = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;ParseHdiVideoPages&lt;/span&gt;(items);&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;foreach&lt;/span&gt; (&lt;span style="color:#0000ff"&gt;var&lt;/span&gt; url &lt;span style="color:#0000ff"&gt;in&lt;/span&gt; urls)&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;{&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;parser.ProcessUrl(url);&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#2b91af"&gt;Console&lt;/span&gt;.WriteLine(items[items.Count-&lt;span style="color:#a52a2a"&gt;1&lt;/span&gt;]);&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;}&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#2b91af"&gt;File&lt;/span&gt;.WriteAllText(&lt;span style="color:#a31515"&gt;@&amp;quot;..&amp;#92;..&amp;#92;CSharpZuneReadyHowDoIVideos.rss&amp;quot;&lt;/span&gt;, parser.RetrieveXml());&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;}&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;}&lt;/li&gt; &lt;li&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Listing 1: An abbreviated version of the RSS Feed created by the code for the CreateRssVideo program.&lt;/strong&gt;&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:afae1f2d-aa35-488e-b6cb-aa3a70ad7f2b" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt; &lt;div style="background: #ddd; max-height: 300px; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="color:#a31515"&gt;xml&lt;/span&gt;&lt;span style="color:#0000ff"&gt; &lt;/span&gt;&lt;span style="color:#ff0000"&gt;version&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt;1.0&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt; &lt;/span&gt;&lt;span style="color:#ff0000"&gt;encoding&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt;utf-8&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt; &lt;/span&gt;&lt;span style="color:#ff0000"&gt;standalone&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt;yes&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt;?&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;!--&lt;/span&gt;&lt;span style="color:#008000"&gt;Charlie&amp;#39;s RSS Feed for Videos&lt;/span&gt;&lt;span style="color:#0000ff"&gt;--&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;rss&lt;/span&gt;&lt;span style="color:#0000ff"&gt; &lt;/span&gt;&lt;span style="color:#ff0000"&gt;version&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt;2.0&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;channel&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;title&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;CSharp How Do I Video Custom Feed for Zune Software&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;title&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;description&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;VS 2010 Related Videos&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;description&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;link&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;http://blogs.msdn.com/charlie&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;link&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;item&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;title&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;Add Tool Windows to the Visual Studio IDE?&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;title&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;description&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;This video demonstrates how to&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;description&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;link&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;http://msdn.microsoft.com/en-us/vstudio/dd250814.aspx&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;link&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;enclosure&lt;/span&gt;&lt;span style="color:#0000ff"&gt; &lt;/span&gt;&lt;span style="color:#ff0000"&gt;url&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt;http://download.microsoft.com/CreatingToolWindows.wmv&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt; &lt;/span&gt;&lt;span style="color:#ff0000"&gt;type&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt;video/x-ms-wmv&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt; /&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;item&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;channel&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;rss&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;The C# code for the &lt;strong&gt;CreateRssVideo&lt;/strong&gt; program uses the build-in &lt;strong&gt;WebClient&lt;/strong&gt; object to download the HTML for the video home page as a string: &lt;/p&gt;  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; RetrieveHtmlFromSite(&lt;span class="kwrd"&gt;string&lt;/span&gt; urlName)
{
    WebClient objWebClient = &lt;span class="kwrd"&gt;new&lt;/span&gt; WebClient();
    &lt;span class="kwrd"&gt;byte&lt;/span&gt;[] requestedUrl = objWebClient.DownloadData(urlName);
    UTF8Encoding utf8 = &lt;span class="kwrd"&gt;new&lt;/span&gt; UTF8Encoding();
    &lt;span class="kwrd"&gt;string&lt;/span&gt; htmlAsString = utf8.GetString(requestedUrl);
    &lt;span class="kwrd"&gt;return&lt;/span&gt; htmlAsString;
}&lt;/pre&gt;

&lt;p&gt;It then uses bits of Regular Expression code to parse the HTML and extract the title, description and video URL from it:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; FindStringInHtmlFile(&lt;span class="kwrd"&gt;string&lt;/span&gt; htmlAsString, &lt;span class="kwrd"&gt;string&lt;/span&gt; regEx)
{
    Regex r = &lt;span class="kwrd"&gt;new&lt;/span&gt; Regex(regEx, RegexOptions.IgnoreCase);

    MatchCollection matchCollection = r.Matches(htmlAsString);
    &lt;span class="kwrd"&gt;string&lt;/span&gt; groupItem = &lt;span class="str"&gt;&amp;quot;&amp;quot;&lt;/span&gt;;

    &lt;span class="kwrd"&gt;if&lt;/span&gt; (matchCollection.Count &amp;gt; 0)
    {
        &lt;span class="kwrd"&gt;foreach&lt;/span&gt; (Group groupItemFound &lt;span class="kwrd"&gt;in&lt;/span&gt; matchCollection[0].Groups)
        {
            groupItem = groupItemFound.Value;
        }
    }
    &lt;span class="kwrd"&gt;return&lt;/span&gt; groupItem;
}        &lt;/pre&gt;

&lt;p&gt;Below is a sample of one of the simple regular expressions that I pass into the &lt;strong&gt;FindStringInHtmlFile &lt;/strong&gt;method. This particular bit of code is used to retrieve the description of the video from the HTML file:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; regExDescriptionText = &lt;span class="str"&gt;@&amp;quot;([A-Z\s0-9#\.,\(\)\-]+)&amp;quot;&lt;/span&gt;;
&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; regExDescription = &lt;span class="str"&gt;@&amp;quot;&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;About this Video&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;&amp;quot;&lt;/span&gt; + regExDescriptionText;&lt;/pre&gt;

&lt;p&gt;While we are parsing the HTML, the program works step by step to create the RSS document using LINQ to XML. The first stage in the RSS creation is to new-up an outline or shell that will hold the meat of the document:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Start()
{
    &lt;span class="kwrd"&gt;string&lt;/span&gt; link = &lt;span class="str"&gt;&amp;quot;http://blogs.msdn.com/charlie&amp;quot;&lt;/span&gt;;
    &lt;span class="kwrd"&gt;string&lt;/span&gt; title = &lt;span class="str"&gt;&amp;quot;CSharp How Do I Video Custom Feed for Zune Software&amp;quot;&lt;/span&gt;;
    &lt;span class="kwrd"&gt;string&lt;/span&gt; description = &lt;span class="str"&gt;&amp;quot;VS 2010 Related Videos&amp;quot;&lt;/span&gt;;

    theDocument = &lt;span class="kwrd"&gt;new&lt;/span&gt; XDocument(&lt;span class="kwrd"&gt;new&lt;/span&gt; XDeclaration(&lt;span class="str"&gt;&amp;quot;1.0&amp;quot;&lt;/span&gt;, &lt;span class="str"&gt;&amp;quot;utf-8&amp;quot;&lt;/span&gt;, &lt;span class="str"&gt;&amp;quot;yes&amp;quot;&lt;/span&gt;),
        &lt;span class="kwrd"&gt;new&lt;/span&gt; XComment(&lt;span class="str"&gt;&amp;quot;Charlie's RSS Feed for Videos&amp;quot;&lt;/span&gt;),
        GetChannel(link, title, description));
}        

&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; XElement GetChannel(&lt;span class="kwrd"&gt;string&lt;/span&gt; link, &lt;span class="kwrd"&gt;string&lt;/span&gt; title, &lt;span class="kwrd"&gt;string&lt;/span&gt; description)
{
    &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;new&lt;/span&gt; XElement(&lt;span class="str"&gt;&amp;quot;rss&amp;quot;&lt;/span&gt;, &lt;span class="kwrd"&gt;new&lt;/span&gt; XAttribute(&lt;span class="str"&gt;&amp;quot;version&amp;quot;&lt;/span&gt;, &lt;span class="str"&gt;&amp;quot;2.0&amp;quot;&lt;/span&gt;),
        &lt;span class="kwrd"&gt;new&lt;/span&gt; XElement(&lt;span class="str"&gt;&amp;quot;channel&amp;quot;&lt;/span&gt;,
                        &lt;span class="kwrd"&gt;new&lt;/span&gt; XElement(&lt;span class="str"&gt;&amp;quot;title&amp;quot;&lt;/span&gt;, title),
                        &lt;span class="kwrd"&gt;new&lt;/span&gt; XElement(&lt;span class="str"&gt;&amp;quot;description&amp;quot;&lt;/span&gt;, description),
                        &lt;span class="kwrd"&gt;new&lt;/span&gt; XElement(&lt;span class="str"&gt;&amp;quot;link&amp;quot;&lt;/span&gt;, link)));
}&lt;/pre&gt;

&lt;p&gt;The &lt;strong&gt;Start&lt;/strong&gt; method creates the document itself, including an XML declaration and a comment. The &lt;strong&gt;GetChannel&lt;/strong&gt; method adds a few simple fields to the document that describes its purpose and which list the URL for my home page. Compare this code with the first few lines from Listing 1 to be sure you understand its purpose. &lt;/p&gt;

&lt;p&gt;As the information for each HDI video is discovered, a new &lt;strong&gt;&amp;lt;item&amp;gt;&lt;/strong&gt; node is created for the RSS feed. This node lists the title for the video, describes the video, and references the URL for the HTML page where the video is stored. Finally, and most importantly, the code includes the &lt;strong&gt;&amp;lt;enclosure&amp;gt;&lt;/strong&gt; node which stores the URL of the actual video. It is the &lt;strong&gt;&amp;lt;enclosure&amp;gt;&lt;/strong&gt; node that the Zune software uses to locate the video which it downloads to your system:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; XElement GetItem(&lt;span class="kwrd"&gt;string&lt;/span&gt; itemTitle, &lt;span class="kwrd"&gt;string&lt;/span&gt; description, &lt;span class="kwrd"&gt;string&lt;/span&gt; linkUrl, &lt;span class="kwrd"&gt;string&lt;/span&gt; videoUrl)
{
    XElement item = &lt;span class="kwrd"&gt;new&lt;/span&gt; XElement(&lt;span class="str"&gt;&amp;quot;item&amp;quot;&lt;/span&gt;,
                &lt;span class="kwrd"&gt;new&lt;/span&gt; XElement(&lt;span class="str"&gt;&amp;quot;title&amp;quot;&lt;/span&gt;, itemTitle),
                &lt;span class="kwrd"&gt;new&lt;/span&gt; XElement(&lt;span class="str"&gt;&amp;quot;description&amp;quot;&lt;/span&gt;, description),
                &lt;span class="kwrd"&gt;new&lt;/span&gt; XElement(&lt;span class="str"&gt;&amp;quot;link&amp;quot;&lt;/span&gt;, linkUrl),
                &lt;span class="kwrd"&gt;new&lt;/span&gt; XElement(&lt;span class="str"&gt;&amp;quot;enclosure&amp;quot;&lt;/span&gt;,
                    &lt;span class="kwrd"&gt;new&lt;/span&gt; XAttribute(&lt;span class="str"&gt;&amp;quot;url&amp;quot;&lt;/span&gt;, videoUrl), &lt;span class="kwrd"&gt;new&lt;/span&gt; XAttribute(&lt;span class="str"&gt;&amp;quot;type&amp;quot;&lt;/span&gt;, &lt;span class="str"&gt;&amp;quot;video/x-ms-wmv&amp;quot;&lt;/span&gt;)));
    &lt;span class="kwrd"&gt;return&lt;/span&gt; item;
}&lt;/pre&gt;

&lt;p&gt;Once the &lt;strong&gt;&amp;lt;item&amp;gt;&lt;/strong&gt; node has been created, it is added to the XML document itself:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; AddItem(&lt;span class="kwrd"&gt;string&lt;/span&gt; itemTitle, &lt;span class="kwrd"&gt;string&lt;/span&gt; description, &lt;span class="kwrd"&gt;string&lt;/span&gt; linkUrl, &lt;span class="kwrd"&gt;string&lt;/span&gt; videoUrl)
{            
    XElement item = GetItem(itemTitle, description, linkUrl, videoUrl);            

    var linkNode = from x &lt;span class="kwrd"&gt;in&lt;/span&gt; theDocument.Descendants(&lt;span class="str"&gt;&amp;quot;link&amp;quot;&lt;/span&gt;)
                   select x;
    
    linkNode.First().AddAfterSelf(item);            
}&lt;/pre&gt;

&lt;p&gt;Note that this code includes a simple LINQ query used to discover the proper insertion point in the XML document, and then employs the LINQ to XML &lt;strong&gt;AddAfterSelf&lt;/strong&gt; operator to insert the new &lt;strong&gt;&amp;lt;item&amp;gt;&lt;/strong&gt; XML node into the code for the RSS feed. The program enters and loop and repeats the process of creating and inserting &lt;strong&gt;&amp;lt;item&amp;gt; &lt;/strong&gt;nodes into our RSS feed multiple times. Once all the URLs in our &lt;strong&gt;UrlsToProcess.txt&lt;/strong&gt; document have been examined the program exits.&lt;/p&gt;

&lt;h2&gt;Summary&lt;/h2&gt;

&lt;p&gt;The primary purpose of this post is to provide an RSS feed that you can use to download videos for viewing in the Zune software or in the Zune itself. I also showed a simple, and very brittle, screen scraping program that I used to create the feed. I wrote this program for my own use, and pass it on to you with only minimal claims of its value. If nothing else, it provides some examples of how to have fun writing Regular Expressions, and demonstrates how easy it is to use LINQ to Objects and LINQ to XML to create XML documents.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;The &lt;a href="http://www.elvenware.com/charlie/rss/CSharpZuneReadyHowDoIVideos.rss"&gt;video feed&lt;/a&gt;. &lt;/li&gt;

  &lt;li&gt;The &lt;a href="http://code.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=linqfarm&amp;amp;DownloadId=7971"&gt;source&lt;/a&gt; from the &lt;a href="http://code.msdn.microsoft.com/linqfarm"&gt;LINQ farm&lt;/a&gt;. &lt;/li&gt;
&lt;/ul&gt;
&lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fblogs.msdn.com%2fcharlie%2farchive%2f2009%2f11%2f01%2fcsharp-how-do-i-videos-for-the-zune-software.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fblogs.msdn.com%2fcharlie%2farchive%2f2009%2f11%2f01%2fcsharp-how-do-i-videos-for-the-zune-software.aspx" /&gt;&lt;/a&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9915933" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/charlie/archive/tags/CSharp/default.aspx">CSharp</category><category domain="http://blogs.msdn.com/charlie/archive/tags/Visual+Studio/default.aspx">Visual Studio</category><category domain="http://blogs.msdn.com/charlie/archive/tags/Samples/default.aspx">Samples</category><category domain="http://blogs.msdn.com/charlie/archive/tags/Video/default.aspx">Video</category><category domain="http://blogs.msdn.com/charlie/archive/tags/C_2300_+4.0/default.aspx">C# 4.0</category><category domain="http://blogs.msdn.com/charlie/archive/tags/Web/default.aspx">Web</category></item><item><title>Publishing an ASP.NET Web Application in IIS</title><link>http://blogs.msdn.com/charlie/archive/2009/04/08/publishing-an-asp-net-web-application-in-iis.aspx</link><pubDate>Wed, 08 Apr 2009 20:11:42 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9538574</guid><dc:creator>Charlie Calvert</dc:creator><slash:comments>7</slash:comments><comments>http://blogs.msdn.com/charlie/comments/9538574.aspx</comments><wfw:commentRss>http://blogs.msdn.com/charlie/commentrss.aspx?PostID=9538574</wfw:commentRss><description>&lt;p&gt;I had a need to publish a Web Application from Visual Studio 2008 into IIS, rather than into the default Visual Studio Development Server. I already had IIS installed, but I wasn’t quite sure what to do next. Here are some notes that I took on what turned out to be a three step process to publish an ASP.NET Web Application to my IIS Web Server:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Run Visual Studio as an Administrator and go to the Web Page in the Properties for the Web Application. I did that by right clicking on the Properties node in the Solution Explorer. On the Web page in the Properties dialog I switched from “Use Visual Studio Development Server” to “Use IIS Web Server.” &lt;/li&gt;    &lt;li&gt;As shown in Figure 1, I then went to the Control Panel and opened this page &lt;strong&gt;Control Panel\Programs\Programs and Features &lt;/strong&gt;and choose:       &lt;ol&gt;       &lt;li&gt;Internet Information Services          &lt;ol&gt;           &lt;li&gt;Web Management Tools              &lt;ol&gt;               &lt;li&gt;IIS 6 Management Compatibility                  &lt;ol&gt;                   &lt;li&gt;IIS Metabase and IIS 6 configuration compatibility &lt;/li&gt;                 &lt;/ol&gt;               &lt;/li&gt;             &lt;/ol&gt;           &lt;/li&gt;         &lt;/ol&gt;       &lt;/li&gt;     &lt;/ol&gt;   &lt;/li&gt;    &lt;li&gt;Still in the Control, I want to &lt;strong&gt;Control Panel\Programs\Programs and Features &lt;/strong&gt;and choose:       &lt;ol&gt;       &lt;li&gt;World Wide Web Services          &lt;ol&gt;           &lt;li&gt;Application Development Features              &lt;ol&gt;               &lt;li&gt;ASP.NET &lt;/li&gt;             &lt;/ol&gt;           &lt;/li&gt;         &lt;/ol&gt;       &lt;/li&gt;     &lt;/ol&gt;   &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Steps 2 and 3 are illustrated in Figure 1. Note that &lt;strong&gt;IIS Metabase and IIS 6 configuration compatibility&lt;/strong&gt; and &lt;strong&gt;ASP.NET&lt;/strong&gt; are both selected. When I selected ASP.NET, a number of other options were turned on automatically.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/charlie/WindowsLiveWriter/PublishingaWebApplicationinIIS_10833/Figure01_2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Figure01" border="0" alt="Figure01" src="http://blogs.msdn.com/blogfiles/charlie/WindowsLiveWriter/PublishingaWebApplicationinIIS_10833/Figure01_thumb.png" width="622" height="528" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;After taking these steps, the &lt;strong&gt;Create Virtual Directory &lt;/strong&gt;button in the Web Page of the Properties for my Web Application worked. I was then able to reach the application by typing a URL such as the following into IIS:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;strong&gt;http://localhost/WebApplication2/&lt;/strong&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;The actual application with my source code remained in the directory where I did my development. The connection between the Virtual Directory and the directory where the application is actually stored can be viewed and configured with the IIS Manager. You can access the Manager here: &lt;strong&gt;Control Panel\System and Maintenance\Administrative Tools. &lt;/strong&gt;In the &lt;strong&gt;Connections &lt;/strong&gt;window on the left of the Manager, browse to &lt;strong&gt;Sites\Default Site &lt;/strong&gt;and click on one of the IIS options such as &lt;strong&gt;Authentication&lt;/strong&gt;.&lt;strong&gt;&amp;#160;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;In the &lt;strong&gt;Actions&lt;/strong&gt; window on the right of the Manager, choose View Applications, then right click on your application and choose &lt;strong&gt;Basic Settings. &lt;/strong&gt;The dialog shown in Figure 2 appears. You can use this dialog to modify the path to your application. If you then want to switch back to developing your source code in the original location inside Visual Studio, you may have to use the IIS Manager to remove the application.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/charlie/WindowsLiveWriter/PublishingaWebApplicationinIIS_10833/Figure02_2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Figure02" border="0" alt="Figure02" src="http://blogs.msdn.com/blogfiles/charlie/WindowsLiveWriter/PublishingaWebApplicationinIIS_10833/Figure02_thumb.png" width="526" height="360" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Handling IIS security and set up issues is a subject that I sometimes find a bit challenging, but the information I’ve outlined here solved my problems, and allowed my to proceed with my work.&lt;/p&gt; &lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fblogs.msdn.com%2fcharlie%2farchive%2f2009%2f04%2f08%2fpublishing-an-asp-net-web-application-in-iis.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fblogs.msdn.com%2fcharlie%2farchive%2f2009%2f04%2f08%2fpublishing-an-asp-net-web-application-in-iis.aspx" /&gt;&lt;/a&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9538574" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/charlie/archive/tags/Visual+Studio/default.aspx">Visual Studio</category><category domain="http://blogs.msdn.com/charlie/archive/tags/Web/default.aspx">Web</category></item></channel></rss>