<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>MattChepeleff.com &#187; Code</title>
	<atom:link href="http://www.mattchepeleff.com/index.php/tag/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mattchepeleff.com</link>
	<description>Web Development, Design, Photography &#38; More</description>
	<lastBuildDate>Sat, 30 Jan 2010 09:21:47 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Using Wordpress/MySql as a CMS for a .NET Site</title>
		<link>http://www.mattchepeleff.com/index.php/2010/01/using-wordpressmysql-as-a-cms-for-a-net-site/</link>
		<comments>http://www.mattchepeleff.com/index.php/2010/01/using-wordpressmysql-as-a-cms-for-a-net-site/#comments</comments>
		<pubDate>Sat, 30 Jan 2010 09:16:18 +0000</pubDate>
		<dc:creator>Matt Chepeleff</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://www.mattchepeleff.com/?p=567</guid>
		<description><![CDATA[<div><p>I&#8217;ve got a couple of projects I&#8217;m working on that are written in C#/.NET and each have a lot of static content.  &#8220;Static&#8221; meaning about us, product description, and FAQ-ish content.  Stupidly, I&#8217;ve got these pages as hard-coded HTML for one site and database driven through a primitive &#8220;CMS&#8221; for the other (I use quotes because I merely put this database-driven content into a <a href="http://tinymce.moxiecode.com/" target="_blank">TinyMCE</a> enabled field on a back-end site and let users have at formatting).</p>
<p>Obviously the hard-coded solution isn&#8217;t the way to go because every change requires a new build onto the server &#8211; which is overkill to say the least.  The quick-and-dirty WYSIWYG/database solution is only marginally better in my opinion (no saved versions and all the text is free form, so associating other fields like data posted, modified, or author requires incremental work).</p>
<p>While thinking up a better way to handle this content I realized both sites also have a <a href="http://wordpress.org/" target="_blank">Wordpress</a> powered blog.  The business users are already used to Wordpress and it&#8217;s a great platform&#8230;plus it&#8217;s a more powerful CMS out of the box.  That got me thinking: Why not setup an additional Wordpress site at static.domain.com (or something) and let ......</div>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve got a couple of projects I&#8217;m working on that are written in C#/.NET and each have a lot of static content.  &#8220;Static&#8221; meaning about us, product description, and FAQ-ish content.  Stupidly, I&#8217;ve got these pages as hard-coded HTML for one site and database driven through a primitive &#8220;CMS&#8221; for the other (I use quotes because I merely put this database-driven content into a <a href="http://tinymce.moxiecode.com/" target="_blank">TinyMCE</a> enabled field on a back-end site and let users have at formatting).</p>
<p>Obviously the hard-coded solution isn&#8217;t the way to go because every change requires a new build onto the server &#8211; which is overkill to say the least.  The quick-and-dirty WYSIWYG/database solution is only marginally better in my opinion (no saved versions and all the text is free form, so associating other fields like data posted, modified, or author requires incremental work).</p>
<p>While thinking up a better way to handle this content I realized both sites also have a <a href="http://wordpress.org/" target="_blank">Wordpress</a> powered blog.  The business users are already used to Wordpress and it&#8217;s a great platform&#8230;plus it&#8217;s a more powerful CMS out of the box.  That got me thinking: Why not setup an additional Wordpress site at static.domain.com (or something) and let the business users handle the static content in this familiar environment.  This would enable the business users, make my life easier, and make the world a better place.</p>
<p>This approach does, in addition to a few other things, require the existing .NET sites to be able to talk to Wordpress&#8217; database and grab the right content.  More specifically, here&#8217;s what needs to be done conceptually:</p>
<ol style="padding:0px;margin-left:30px;">
<li>Setup the new Wordpress environment for storage of the new &#8220;static&#8221; content</li>
<li>Install the<a href="http://dev.mysql.com/downloads/connector/net/5.2.html" target="_blank"> MySQL Connector/Net</a> so .NET can talk to MySQL</li>
<li>Write code in C# to pull content out of the MySQL database</li>
</ol>
<p>Now the only other thing we need to figure out is how we&#8217;re going to grab an individual record from the <span style="font-family: Courier,monospace;">wp_posts</span> table.  We could query by ID, Title, Author, etc&#8230;  As I need to call content from the existing .NET sites, I want the code to be able to grab something that isn&#8217;t going to change &#8211; like IDs.  Now, you would be correct thinking ahead and wondering how Wordpress stores multiple versions of the same page or post.   That won&#8217;t pose issues, because the <span style="font-family: Courier,monospace;">post_parent</span> field always references the original post:</p>
<p style="text-align: center;"><a href="http://www.mattchepeleff.com/wp-content/uploads/2010/01/mysql1.gif" rel='gb_imageset[using-wordpressmysql-as-a-cms-for-a-net-site]'><img class="aligncenter size-full wp-image-569" title="MySQL wp_posts Query" src="http://www.mattchepeleff.com/wp-content/uploads/2010/01/mysql1.gif" alt="MySQL wp_posts Query" width="514" height="342" /></a></p>
<p>But I don&#8217;t want to use the ID because Wordpress users can&#8217;t modify it if something changes.  Fortunately, Wordpress allows a user to quickly add custom fields &#8211; so we&#8217;ll go this route because it gives the business users more control and they&#8217;ll like this (feel more important).</p>
<p>Before I get to the code, let&#8217;s quickly recap.  From .NET I will call some code that will lookup a post in the <span style="font-family: Courier,monospace;">wp_posts</span> table using a custom field value.  In Wordpress, all that a user needs to do is add this custom field &#8211; the code will look up the most recent revision and handle the rest.</p>
<p>Here&#8217;s a class I wrote in C#:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
</pre></td><td class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #FF0000;">class</span> WordPressPostInfo
<span style="color: #000000;">&#123;</span>
    <span style="color: #008080;">#region private variables</span>
    <span style="color: #FF0000;">string</span> _title, _content, _name, _excerpt, _status, _password, _type, _mimetype, _posternicename, _posterdisplayname, _posteremail, _websiteloc<span style="color: #008000;">;</span>
    DateTime _posted, _postedgmt, _modified, _modifiedgmt<span style="color: #008000;">;</span>
    <span style="color: #FF0000;">int</span> _posterId<span style="color: #008000;">;</span>
    <span style="color: #008080;">#endregion</span>
&nbsp;
    <span style="color: #008080;">#region public attributes</span>
    <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// The Post Title</span>
    <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
    <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">string</span> Title
    <span style="color: #000000;">&#123;</span>
        get <span style="color: #000000;">&#123;</span> <span style="color: #0600FF;">return</span> _title<span style="color: #008000;">;</span> <span style="color: #000000;">&#125;</span>
        set <span style="color: #000000;">&#123;</span> _title <span style="color: #008000;">=</span> value<span style="color: #008000;">;</span> <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// The Post Content</span>
    <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
    <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">string</span> Content
    <span style="color: #000000;">&#123;</span>
        get <span style="color: #000000;">&#123;</span> <span style="color: #0600FF;">return</span> _content<span style="color: #008000;">;</span> <span style="color: #000000;">&#125;</span>
        set <span style="color: #000000;">&#123;</span> _content <span style="color: #008000;">=</span> value<span style="color: #008000;">;</span> <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// The Post Name</span>
    <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
    <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">string</span> Name
    <span style="color: #000000;">&#123;</span>
        get <span style="color: #000000;">&#123;</span> <span style="color: #0600FF;">return</span> _name<span style="color: #008000;">;</span> <span style="color: #000000;">&#125;</span>
        set <span style="color: #000000;">&#123;</span> _name <span style="color: #008000;">=</span> value<span style="color: #008000;">;</span> <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// The Post Excerpt</span>
    <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
    <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">string</span> Excerpt
    <span style="color: #000000;">&#123;</span>
        get <span style="color: #000000;">&#123;</span> <span style="color: #0600FF;">return</span> _excerpt<span style="color: #008000;">;</span> <span style="color: #000000;">&#125;</span>
        set <span style="color: #000000;">&#123;</span> _excerpt <span style="color: #008000;">=</span> value<span style="color: #008000;">;</span> <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// The Post Status</span>
    <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
    <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">string</span> Status
    <span style="color: #000000;">&#123;</span>
        get <span style="color: #000000;">&#123;</span> <span style="color: #0600FF;">return</span> _status<span style="color: #008000;">;</span> <span style="color: #000000;">&#125;</span>
        set <span style="color: #000000;">&#123;</span> _status <span style="color: #008000;">=</span> value<span style="color: #008000;">;</span> <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// The Post Password</span>
    <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
    <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">string</span> Password
    <span style="color: #000000;">&#123;</span>
        get <span style="color: #000000;">&#123;</span> <span style="color: #0600FF;">return</span> _password<span style="color: #008000;">;</span> <span style="color: #000000;">&#125;</span>
        set <span style="color: #000000;">&#123;</span> _password <span style="color: #008000;">=</span> value<span style="color: #008000;">;</span> <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// The Post Date/Time Originally Posted</span>
    <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
    <span style="color: #0600FF;">public</span> DateTime Posted
    <span style="color: #000000;">&#123;</span>
        get <span style="color: #000000;">&#123;</span> <span style="color: #0600FF;">return</span> _posted<span style="color: #008000;">;</span> <span style="color: #000000;">&#125;</span>
        set <span style="color: #000000;">&#123;</span> _posted <span style="color: #008000;">=</span> value<span style="color: #008000;">;</span> <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// The Post Date/Time Originally Posted (GMT)</span>
    <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
    <span style="color: #0600FF;">public</span> DateTime PostedGMT
    <span style="color: #000000;">&#123;</span>
        get <span style="color: #000000;">&#123;</span> <span style="color: #0600FF;">return</span> _postedgmt<span style="color: #008000;">;</span> <span style="color: #000000;">&#125;</span>
        set <span style="color: #000000;">&#123;</span> _postedgmt <span style="color: #008000;">=</span> value<span style="color: #008000;">;</span> <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// The Post Date/Time Modified</span>
    <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
    <span style="color: #0600FF;">public</span> DateTime Modified
    <span style="color: #000000;">&#123;</span>
        get <span style="color: #000000;">&#123;</span> <span style="color: #0600FF;">return</span> _modified<span style="color: #008000;">;</span> <span style="color: #000000;">&#125;</span>
        set <span style="color: #000000;">&#123;</span> _modified <span style="color: #008000;">=</span> value<span style="color: #008000;">;</span> <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// The Post Date/Time Modified (GMT)</span>
    <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
    <span style="color: #0600FF;">public</span> DateTime ModifiedGMT
    <span style="color: #000000;">&#123;</span>
        get <span style="color: #000000;">&#123;</span> <span style="color: #0600FF;">return</span> _modifiedgmt<span style="color: #008000;">;</span> <span style="color: #000000;">&#125;</span>
        set <span style="color: #000000;">&#123;</span> _modifiedgmt <span style="color: #008000;">=</span> value<span style="color: #008000;">;</span> <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// The Post MIME Type</span>
    <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
    <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">string</span> MimeType
    <span style="color: #000000;">&#123;</span>
        get <span style="color: #000000;">&#123;</span> <span style="color: #0600FF;">return</span> _mimetype<span style="color: #008000;">;</span> <span style="color: #000000;">&#125;</span>
        set <span style="color: #000000;">&#123;</span> _mimetype <span style="color: #008000;">=</span> value<span style="color: #008000;">;</span> <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// The Post Publish Status</span>
    <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
    <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">bool</span> IsPublished
    <span style="color: #000000;">&#123;</span>
        get
        <span style="color: #000000;">&#123;</span>
            <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>Status <span style="color: #008000;">==</span> <span style="color: #666666;">&quot;publish&quot;</span> <span style="color: #008000;">||</span> Status <span style="color: #008000;">==</span> <span style="color: #666666;">&quot;inherit&quot;</span><span style="color: #000000;">&#41;</span>
                <span style="color: #0600FF;">return</span> true<span style="color: #008000;">;</span>
            <span style="color: #0600FF;">else</span>
                <span style="color: #0600FF;">return</span> false<span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// The Post Type</span>
    <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
    <span style="color: #0600FF;">public</span> PostType Type
    <span style="color: #000000;">&#123;</span>
        get
        <span style="color: #000000;">&#123;</span>
            <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>_type <span style="color: #008000;">==</span> <span style="color: #666666;">&quot;post&quot;</span><span style="color: #000000;">&#41;</span>
                <span style="color: #0600FF;">return</span> PostType.<span style="color: #0000FF;">Post</span><span style="color: #008000;">;</span>
            <span style="color: #0600FF;">else</span> <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>_type <span style="color: #008000;">==</span> <span style="color: #666666;">&quot;page&quot;</span><span style="color: #000000;">&#41;</span>
                <span style="color: #0600FF;">return</span> PostType.<span style="color: #0000FF;">Page</span><span style="color: #008000;">;</span>
            <span style="color: #0600FF;">else</span> <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>_type <span style="color: #008000;">==</span> <span style="color: #666666;">&quot;revision&quot;</span><span style="color: #000000;">&#41;</span>
                <span style="color: #0600FF;">return</span> PostType.<span style="color: #0000FF;">Revision</span><span style="color: #008000;">;</span>
            <span style="color: #0600FF;">else</span>
                <span style="color: #0600FF;">return</span> PostType.<span style="color: #0000FF;">Unknown</span><span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// The Poster's Wordpress &quot;Nice Name&quot;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
    <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">string</span> PosterNiceName
    <span style="color: #000000;">&#123;</span>
        get <span style="color: #000000;">&#123;</span> <span style="color: #0600FF;">return</span> _posternicename<span style="color: #008000;">;</span> <span style="color: #000000;">&#125;</span>
        set <span style="color: #000000;">&#123;</span> _posternicename <span style="color: #008000;">=</span> value<span style="color: #008000;">;</span> <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// The Poster's Wordpress &quot;Display Name&quot;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
    <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">string</span> PosterDisplayName
    <span style="color: #000000;">&#123;</span>
        get <span style="color: #000000;">&#123;</span> <span style="color: #0600FF;">return</span> _posterdisplayname<span style="color: #008000;">;</span> <span style="color: #000000;">&#125;</span>
        set <span style="color: #000000;">&#123;</span> _posterdisplayname <span style="color: #008000;">=</span> value<span style="color: #008000;">;</span> <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// The Poster's Wordpress Email</span>
    <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
    <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">string</span> PosterEmail
    <span style="color: #000000;">&#123;</span>
        get <span style="color: #000000;">&#123;</span> <span style="color: #0600FF;">return</span> _posteremail<span style="color: #008000;">;</span> <span style="color: #000000;">&#125;</span>
        set <span style="color: #000000;">&#123;</span> _posteremail <span style="color: #008000;">=</span> value<span style="color: #008000;">;</span> <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// The Website Location to display this post (set in Wordpress as custom field with name &quot;websiteDisplayLocation&quot;)</span>
    <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
    <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">string</span> WebsiteLocation
    <span style="color: #000000;">&#123;</span>
        get <span style="color: #000000;">&#123;</span> <span style="color: #0600FF;">return</span> _websiteloc<span style="color: #008000;">;</span> <span style="color: #000000;">&#125;</span>
        set <span style="color: #000000;">&#123;</span> _websiteloc <span style="color: #008000;">=</span> value<span style="color: #008000;">;</span> <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
    <span style="color: #008080;">#endregion</span>
&nbsp;
    <span style="color: #008080;">#region constructors</span>
    <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// default constructor</span>
    <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
    <span style="color: #0600FF;">public</span> WordPressPostInfo<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span> <span style="color: #000000;">&#125;</span>
&nbsp;
    <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// construct by website location custom field in Wordpress</span>
    <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;param name=&quot;WebsiteLocation&quot;&gt;&lt;/param&gt;</span>
    <span style="color: #0600FF;">public</span> WordPressPostInfo<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">string</span> WebsiteLocation<span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
        GetSinglePost<span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;wp_postmeta.meta_value&quot;</span>, WebsiteLocation<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #000000;">&#125;</span>
&nbsp;
    <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// construct by post title</span>
    <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;param name=&quot;PostTitle&quot;&gt;&lt;/param&gt;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;param name=&quot;byTitle&quot;&gt;&lt;/param&gt;</span>
    <span style="color: #0600FF;">public</span> WordPressPostInfo<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">string</span> PostTitle, <span style="color: #FF0000;">bool</span> byTitle<span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
        GetSinglePost<span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;post_title&quot;</span>, PostTitle<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #000000;">&#125;</span>
&nbsp;
    <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// private construct by MySqlDataReader</span>
    <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;param name=&quot;reader&quot;&gt;&lt;/param&gt;</span>
    <span style="color: #0600FF;">private</span> WordPressPostInfo<span style="color: #000000;">&#40;</span>MySqlDataReader reader<span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
        FillWordPressObj<span style="color: #000000;">&#40;</span>reader<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #000000;">&#125;</span>
    <span style="color: #008080;">#endregion</span>
&nbsp;
    <span style="color: #008080;">#region methods</span>
    <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// Get a single post</span>
    <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;param name=&quot;title&quot;&gt;&lt;/param&gt;</span>
    <span style="color: #0600FF;">protected</span> <span style="color: #0600FF;">void</span> GetSinglePost<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">string</span> byField, <span style="color: #FF0000;">string</span> byValue<span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
        <span style="color: #FF0000;">string</span> strProvider <span style="color: #008000;">=</span> ConfigurationManager.<span style="color: #0000FF;">AppSettings</span><span style="color: #000000;">&#91;</span><span style="color: #666666;">&quot;mysqlConnectionString&quot;</span><span style="color: #000000;">&#93;</span>.<span style="color: #0000FF;">ToString</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        MySqlConnection mySql <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> MySqlConnection<span style="color: #000000;">&#40;</span>strProvider<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        mySql.<span style="color: #0000FF;">Open</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #FF0000;">string</span> query <span style="color: #008000;">=</span> <span style="color: #FF0000;">string</span>.<span style="color: #0000FF;">Format</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;select wp_posts.*, wp_postmeta.meta_value as websiteLoc, wp_users.display_name, wp_users.user_nicename, wp_users.user_email from wp_posts left join wp_postmeta ON wp_posts.ID = wp_postmeta.post_id AND wp_postmeta.meta_key = 'websiteDisplayLocation' inner join wp_users on wp_posts.post_author = wp_users.ID where {0} = '{1}' AND post_status = 'publish' ORDER BY ID ASC LIMIT 1&quot;</span>, byField, byValue<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        MySqlCommand mysqlCmd <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> MySqlCommand<span style="color: #000000;">&#40;</span>query, mySql<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        MySqlDataReader reader <span style="color: #008000;">=</span> mysqlCmd.<span style="color: #0000FF;">ExecuteReader</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #0600FF;">while</span> <span style="color: #000000;">&#40;</span>reader.<span style="color: #0000FF;">Read</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            FillWordPressObj<span style="color: #000000;">&#40;</span>reader<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
        reader.<span style="color: #0000FF;">Close</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        reader.<span style="color: #0000FF;">Dispose</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        mySql.<span style="color: #0000FF;">Close</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        mySql.<span style="color: #0000FF;">Dispose</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #000000;">&#125;</span>
&nbsp;
    <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// Get all the published posts and pages</span>
    <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;param name=&quot;title&quot;&gt;&lt;/param&gt;</span>
    <span style="color: #0600FF;">public</span> List<span style="color: #008000;">&lt;</span>WordPressPostInfo<span style="color: #008000;">&gt;</span> GetAllPosts<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
        <span style="color: #FF0000;">string</span> strProvider <span style="color: #008000;">=</span> ConfigurationManager.<span style="color: #0000FF;">AppSettings</span><span style="color: #000000;">&#91;</span><span style="color: #666666;">&quot;mysqlConnectionString&quot;</span><span style="color: #000000;">&#93;</span>.<span style="color: #0000FF;">ToString</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        MySqlConnection mySql <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> MySqlConnection<span style="color: #000000;">&#40;</span>strProvider<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        mySql.<span style="color: #0000FF;">Open</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #FF0000;">string</span> query <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;select wp_posts.*, wp_postmeta.meta_value as websiteLoc, wp_users.display_name, wp_users.user_nicename, wp_users.user_email from wp_posts left join wp_postmeta ON wp_posts.ID = wp_postmeta.post_id AND wp_postmeta.meta_key = 'websiteDisplayLocation' inner join wp_users on wp_posts.post_author = wp_users.ID where post_status = 'publish'&quot;</span><span style="color: #008000;">;</span>
        MySqlCommand mysqlCmd <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> MySqlCommand<span style="color: #000000;">&#40;</span>query, mySql<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        MySqlDataReader reader <span style="color: #008000;">=</span> mysqlCmd.<span style="color: #0000FF;">ExecuteReader</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
        List<span style="color: #008000;">&lt;</span>WordPressPostInfo<span style="color: #008000;">&gt;</span> posts <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> List<span style="color: #008000;">&lt;</span>WordPressPostInfo<span style="color: #008000;">&gt;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #0600FF;">while</span> <span style="color: #000000;">&#40;</span>reader.<span style="color: #0000FF;">Read</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            posts.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span><span style="color: #008000;">new</span> WordPressPostInfo<span style="color: #000000;">&#40;</span>reader<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
&nbsp;
        reader.<span style="color: #0000FF;">Close</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        mySql.<span style="color: #0000FF;">Close</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        reader.<span style="color: #0000FF;">Dispose</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        mySql.<span style="color: #0000FF;">Dispose</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #0600FF;">return</span> posts<span style="color: #008000;">;</span>
    <span style="color: #000000;">&#125;</span>
&nbsp;
    <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// Fill the main WordpressPostInfo object with the attributes in the reader</span>
    <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;param name=&quot;reader&quot;&gt;&lt;/param&gt;</span>
    <span style="color: #0600FF;">protected</span> <span style="color: #0600FF;">void</span> FillWordPressObj<span style="color: #000000;">&#40;</span>MySqlDataReader reader<span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
        <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">Title</span> <span style="color: #008000;">=</span> reader.<span style="color: #0000FF;">GetString</span><span style="color: #000000;">&#40;</span>reader.<span style="color: #0000FF;">GetOrdinal</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;post_title&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">Content</span> <span style="color: #008000;">=</span> reader.<span style="color: #0000FF;">GetString</span><span style="color: #000000;">&#40;</span>reader.<span style="color: #0000FF;">GetOrdinal</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;post_content&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">Name</span> <span style="color: #008000;">=</span> reader.<span style="color: #0000FF;">GetString</span><span style="color: #000000;">&#40;</span>reader.<span style="color: #0000FF;">GetOrdinal</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;post_name&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">Excerpt</span> <span style="color: #008000;">=</span> reader.<span style="color: #0000FF;">GetString</span><span style="color: #000000;">&#40;</span>reader.<span style="color: #0000FF;">GetOrdinal</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;post_excerpt&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">Status</span> <span style="color: #008000;">=</span> reader.<span style="color: #0000FF;">GetString</span><span style="color: #000000;">&#40;</span>reader.<span style="color: #0000FF;">GetOrdinal</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;post_status&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">Password</span> <span style="color: #008000;">=</span> reader.<span style="color: #0000FF;">GetString</span><span style="color: #000000;">&#40;</span>reader.<span style="color: #0000FF;">GetOrdinal</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;post_password&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">Posted</span> <span style="color: #008000;">=</span> reader.<span style="color: #0000FF;">GetDateTime</span><span style="color: #000000;">&#40;</span>reader.<span style="color: #0000FF;">GetOrdinal</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;post_date&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">PostedGMT</span> <span style="color: #008000;">=</span> reader.<span style="color: #0000FF;">GetDateTime</span><span style="color: #000000;">&#40;</span>reader.<span style="color: #0000FF;">GetOrdinal</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;post_date_gmt&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">Modified</span> <span style="color: #008000;">=</span> reader.<span style="color: #0000FF;">GetDateTime</span><span style="color: #000000;">&#40;</span>reader.<span style="color: #0000FF;">GetOrdinal</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;post_modified&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">ModifiedGMT</span> <span style="color: #008000;">=</span> reader.<span style="color: #0000FF;">GetDateTime</span><span style="color: #000000;">&#40;</span>reader.<span style="color: #0000FF;">GetOrdinal</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;post_modified_gmt&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #0600FF;">this</span>._type <span style="color: #008000;">=</span> reader.<span style="color: #0000FF;">GetString</span><span style="color: #000000;">&#40;</span>reader.<span style="color: #0000FF;">GetOrdinal</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;post_type&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">MimeType</span> <span style="color: #008000;">=</span> reader.<span style="color: #0000FF;">GetString</span><span style="color: #000000;">&#40;</span>reader.<span style="color: #0000FF;">GetOrdinal</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;post_mime_type&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #0600FF;">this</span>._posterId <span style="color: #008000;">=</span> reader.<span style="color: #0000FF;">GetInt32</span><span style="color: #000000;">&#40;</span>reader.<span style="color: #0000FF;">GetOrdinal</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;post_author&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">WebsiteLocation</span> <span style="color: #008000;">=</span> reader.<span style="color: #0000FF;">IsDBNull</span><span style="color: #000000;">&#40;</span>reader.<span style="color: #0000FF;">GetOrdinal</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;websiteLoc&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">?</span> <span style="color: #666666;">&quot;&quot;</span> <span style="color: #008000;">:</span> reader.<span style="color: #0000FF;">GetString</span><span style="color: #000000;">&#40;</span>reader.<span style="color: #0000FF;">GetOrdinal</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;websiteLoc&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">PosterNiceName</span> <span style="color: #008000;">=</span> reader.<span style="color: #0000FF;">GetString</span><span style="color: #000000;">&#40;</span>reader.<span style="color: #0000FF;">GetOrdinal</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;user_nicename&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">PosterDisplayName</span> <span style="color: #008000;">=</span> reader.<span style="color: #0000FF;">GetString</span><span style="color: #000000;">&#40;</span>reader.<span style="color: #0000FF;">GetOrdinal</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;display_name&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">PosterEmail</span> <span style="color: #008000;">=</span> reader.<span style="color: #0000FF;">GetString</span><span style="color: #000000;">&#40;</span>reader.<span style="color: #0000FF;">GetOrdinal</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;user_email&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #000000;">&#125;</span>
    <span style="color: #008080;">#endregion</span>
&nbsp;
    <span style="color: #008080;">#region enums</span>
    <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">enum</span> PostType
    <span style="color: #000000;">&#123;</span>
        Post <span style="color: #008000;">=</span> <span style="color: #FF0000;">1</span>,
        Page <span style="color: #008000;">=</span> <span style="color: #FF0000;">2</span>,
        Revision <span style="color: #008000;">=</span> <span style="color: #FF0000;">3</span>,
        Unknown <span style="color: #008000;">=</span> <span style="color: #FF0000;">4</span>
    <span style="color: #000000;">&#125;</span>
    <span style="color: #008080;">#endregion</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>After you copy over this class it will only take a line of code to get a post for display on your .aspx:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="csharp" style="font-family:monospace;">WordPressPostInfo post <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> WordPressPostInfo<span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;about_us&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span></pre></td></tr></table></div>

<p>Or if you needed to iterate through all of the posts you could use:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="csharp" style="font-family:monospace;">WordPressPostInfo wppi <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> WordPressPostInfo<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
List<span style="color: #008000;">&lt;</span>WordPressPostInfo<span style="color: #008000;">&gt;</span> posts <span style="color: #008000;">=</span> wppi.<span style="color: #0000FF;">GetAllPosts</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #0600FF;">foreach</span> <span style="color: #000000;">&#40;</span>WordPressPostInfo _post <span style="color: #0600FF;">in</span> posts<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
     <span style="color: #008080; font-style: italic;">//do something with each post here</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>Each <span style="font-family: Courier,monospace;">WordPressPostInfo</span> object is going to contain all the fields you might want to display in the UI, so it should be easy from here.  While we do have to hardcode the call to the post on the .aspx &#8211; the source of the content can be changes and updated easily from Wordpress now!</p>
<p>A few notes to get this class working in your project:</p>
<ul style="padding:0px;margin-left:30px;">
<li>Be sure to add a reference to MySql.Data to your project first, then add:<br />
<span style="font-family: Courier,monospace;">using System.Configuration;<br />
using MySql.Data.MySqlClient;<br />
using MySql.Data.Types;</span></li>
<li> Add the assembly to your web.config under compilation &gt; assemblies:<br />
<span style="font-family: Courier,monospace;">&lt;add assembly=&#8221;MySql.Data, Version=5.2.5.0, Culture=neutral, PublicKeyToken=C5687FC88969C44D&#8221;/&gt;</span></li>
<li> Add the connection string App Setting your web.config too:<br />
<span style="font-family: Courier,monospace;">&lt;add key=&#8221;mysqlConnectionString&#8221; value=&#8221;Data Source=localhost;Database=your_databaseName;User ID=your_userId;Password=your_password;&#8221;/&gt; </span></li>
<li><span style="font-family: Courier, monospace;"><span style="font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;">I&#8217;m using a custom field in Wordpress called </span>websiteDisplayLocation<span style="font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;"> so be sure you use this field name or change the code</span></span></li>
<li><span style="font-family: Courier, monospace;"><span style="font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;">I&#8217;m only returning published status records &#8211; change the SQL as needed if this doesn&#8217;t work for you&#8230;</span></span></li>
<li><span style="font-family: Courier, monospace;"><span style="font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;">The <span style="font-family: Courier,monospace;">Type</span> property can be used to differentiate posts and pages.  I think I&#8217;ll have the end users create posts, but you could use either.  Wordpress stores posts and pages in the same <span style="font-family: Courier,monospace;">wp_posts</span> table.</span></span></li>
</ul>
<p>Other useful reference for this project:</p>
<ul style="padding:0px;margin-left:30px;">
<li><a href="http://codex.wordpress.org/Database_Description" target="_blank">Wordpress&#8217; database schema</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.mattchepeleff.com/index.php/2010/01/using-wordpressmysql-as-a-cms-for-a-net-site/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Easy Windows Batch File Backups (with MySQL, MsSQL, and email notifications included)</title>
		<link>http://www.mattchepeleff.com/index.php/2010/01/easy-windows-batch-file-backups-with-mysql-mssql-and-email-notifications-included/</link>
		<comments>http://www.mattchepeleff.com/index.php/2010/01/easy-windows-batch-file-backups-with-mysql-mssql-and-email-notifications-included/#comments</comments>
		<pubDate>Mon, 11 Jan 2010 08:13:57 +0000</pubDate>
		<dc:creator>Matt Chepeleff</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://www.mattchepeleff.com/?p=534</guid>
		<description><![CDATA[<div><p>Here&#8217;s a post for fellow geeks.  Today I wanted to beef the backups for sites I serve and at the same time keep my brand server clean from software if I could.  I use Mozy Pro on the server but wanted periodic snapshots of sites at different intervals as well.  Only issue is I host sites that use MySQL and MsSQL databases &#8211; so this script accommodates both.  I wrote the following batch file which backs up website source files &#38; databases to a .Rar file.  Then it sends me an email notification not only that a backup has occurred&#8230;but also with the details of all other backup files available.</p>
<p>I scheduled a .bat file with this script in it for each site I host and it drops everything into a single file for me per the schedule frequency.  I&#8217;m even free to email myself or clients their entire application source.</p>
<p>Prerequsites for this script to work are <a href="http://www.rarlab.com/" target="_blank">Winrar</a> (not the free version, but a purchased version as I don&#8217;t think the free versions allow command line interfaces through rar.exe) and <a href="http://caspian.dotconf.net/menu/Software/SendEmail/" target="_blank">SendEmail</a> (free).  I&#8217;ve separated the code a bit so you should be able to customize the top portion with ......</div>]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a post for fellow geeks.  Today I wanted to beef the backups for sites I serve and at the same time keep my brand server clean from software if I could.  I use Mozy Pro on the server but wanted periodic snapshots of sites at different intervals as well.  Only issue is I host sites that use MySQL and MsSQL databases &#8211; so this script accommodates both.  I wrote the following batch file which backs up website source files &amp; databases to a .Rar file.  Then it sends me an email notification not only that a backup has occurred&#8230;but also with the details of all other backup files available.</p>
<p>I scheduled a .bat file with this script in it for each site I host and it drops everything into a single file for me per the schedule frequency.  I&#8217;m even free to email myself or clients their entire application source.</p>
<p>Prerequsites for this script to work are <a href="http://www.rarlab.com/" target="_blank">Winrar</a> (not the free version, but a purchased version as I don&#8217;t think the free versions allow command line interfaces through rar.exe) and <a href="http://caspian.dotconf.net/menu/Software/SendEmail/" target="_blank">SendEmail</a> (free).  I&#8217;ve separated the code a bit so you should be able to customize the top portion with your paths, etc.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
</pre></td><td class="code"><pre class="winbatch" style="font-family:monospace;"><span style="color: #66cc66;">@</span>ECHO <span style="color: #0080FF; font-weight: bold;">off</span>
&nbsp;
REM <span style="color: #66cc66;">***</span> CONFIGURE HERE <span style="color: #66cc66;">&#40;</span>Leave mysql or mssql blank <span style="color: #800080;">to</span> skip database backup<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">***</span>
&nbsp;
SET rootdir=\Inetpub\yourdomain.com
SET siteName=YourDomain.com
SET backupFolder=WWW
&nbsp;
SET mysql=database_name
SET mssql=database_name
&nbsp;
SET mysqlServer=localhost
SET mysqlPass=password
SET mssqlServerInstance=localhost\instanceName
&nbsp;
SET WinRarexeLocation=C<span style="color: #FF1010; font-weight: bold;">:\progra~1\WinRAR\rar</span>
SET sendMailexeLocation=C<span style="color: #FF1010; font-weight: bold;">:\folder_name\sendEmail.exe</span>
&nbsp;
SET emailFromAddress=<span style="color: #ff0000;">&quot;auto_backups@yourdomain.com&quot;</span>
SET emailToAddress=<span style="color: #ff0000;">&quot;steve@yourdomain.com&quot;</span>
SET smtpServer=smtp.yourdomain.com<span style="color: #FF1010; font-weight: bold;">:25</span>
&nbsp;
REM <span style="color: #66cc66;">***</span> Careful editing below this <span style="color: #66cc66;">********************************************</span>
&nbsp;
cd\
cd<span style="color: #66cc66;">%</span>rootdir<span style="color: #66cc66;">%</span>
&nbsp;
REM <span style="color: #66cc66;">***</span> Backup MySQL and<span style="color: #66cc66;">/</span>or MsSQL databases <span style="color: #800080;">if</span> db names specified <span style="color: #66cc66;">***</span>
<span style="color: #800080;">if</span> defined mysql mysqldump <span style="color: #66cc66;">-</span>h <span style="color: #66cc66;">%</span>mysqlServer<span style="color: #66cc66;">%</span> <span style="color: #66cc66;">-</span>u root <span style="color: #66cc66;">-</span>p <span style="color: #66cc66;">%</span>mysql<span style="color: #66cc66;">%</span> <span style="color: #66cc66;">&amp;</span>gt<span style="color: #008000; font-style: italic;">; db_backup.sql --password=%mysqlPass%</span>
<span style="color: #800080;">if</span> defined mssql sqlcmd <span style="color: #66cc66;">-</span>S <span style="color: #ff0000;">&quot;%mssqlServerInstance%&quot;</span> <span style="color: #66cc66;">-</span>Q <span style="color: #ff0000;">&quot;BACKUP DATABASE %mssql% TO DISK = 'C:%rootdir%\%mssql%_db.bak';&quot;</span>
&nbsp;
REM <span style="color: #66cc66;">***</span> <span style="color: #0080FF; font-weight: bold;">Save</span> contents of specified directory <span style="color: #800080;">to</span> .rar archive <span style="color: #66cc66;">***</span>
<span style="color: #66cc66;">%</span>WinRarexeLocation<span style="color: #66cc66;">%</span> a <span style="color: #66cc66;">-</span>agMM_DD_YYYY_HHMMSS BAK .rar <span style="color: #66cc66;">%</span>backupFolderr<span style="color: #66cc66;">%</span> db_backup.sql <span style="color: #66cc66;">%</span>mssql<span style="color: #66cc66;">%</span>_db.bak
&nbsp;
del db_backup.sql
del <span style="color: #66cc66;">%</span>mssql<span style="color: #66cc66;">%</span>_db.bak
&nbsp;
set myDir1=C<span style="color: #FF1010; font-weight: bold;">:%rootdir%\*.rar</span>
set fileinfo=
&nbsp;
<span style="color: #800080;">for</span> <span style="color: #66cc66;">/</span>f <span style="color: #ff0000;">&quot;delims=&quot;</span> <span style="color: #66cc66;">%%</span>a <span style="color: #800080;">in</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'dir /b /a-d %myDir1% 2^&amp;gt;NUL'</span><span style="color: #66cc66;">&#41;</span> do <span style="color: #800080;">call</span> <span style="color: #FF1010; font-weight: bold;">:process %%a %%~zna</span>
<span style="color: #66cc66;">%</span>sendMailexeLocation<span style="color: #66cc66;">%</span> <span style="color: #66cc66;">-</span>f <span style="color: #66cc66;">%</span>emailFromAddress<span style="color: #66cc66;">%</span> <span style="color: #66cc66;">-</span>t <span style="color: #66cc66;">%</span>emailToAddress <span style="color: #66cc66;">-</span>u <span style="color: #ff0000;">&quot;%siteName% Backed Up!&quot;</span> <span style="color: #66cc66;">-</span>s <span style="color: #66cc66;">%</span>smtpServer<span style="color: #66cc66;">%</span> <span style="color: #66cc66;">-</span>m <span style="color: #ff0000;">&quot;All source and/or database files for %siteName% have been backed up.\n\nBackup files available are:\n\nNAME                                   FILE SIZE\n-------------------------------------------------------------\n%fileinfo%\n\nEnjoy!&quot;</span>
&nbsp;
<span style="color: #FF1010; font-weight: bold;">:process</span>
<span style="color: #800080;">if</span> not <span style="color: #ff0000;">&quot;%fileinfo%&quot;</span>==<span style="color: #ff0000;">&quot;&quot;</span> set fileinfo=<span style="color: #66cc66;">%</span>fileinfo<span style="color: #66cc66;">%</span>\n
set fileinfo=<span style="color: #66cc66;">%</span>fileinfo<span style="color: #66cc66;">%%~</span><span style="color: #cc66cc;">1</span>   <span style="color: #66cc66;">%~</span><span style="color: #cc66cc;">2</span></pre></td></tr></table></div>

<p>I put all website source code into a WWW for each site &#8211; so that&#8217;s why I added a backupFolder variable to the script.  You can list as many other files or folders (separated by a space) or use *.* to include all files in the specified folder.</p>
<p>Feel free to customize and use as needed.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mattchepeleff.com/index.php/2010/01/easy-windows-batch-file-backups-with-mysql-mssql-and-email-notifications-included/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New Site, mat.tc API and Wordpress Plugin</title>
		<link>http://www.mattchepeleff.com/index.php/2010/01/new-site-mat-tc-api-and-wordpress-plugin/</link>
		<comments>http://www.mattchepeleff.com/index.php/2010/01/new-site-mat-tc-api-and-wordpress-plugin/#comments</comments>
		<pubDate>Sun, 10 Jan 2010 06:54:47 +0000</pubDate>
		<dc:creator>Matt Chepeleff</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[APIs]]></category>
		<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://www.mattchepeleff.com/?p=518</guid>
		<description><![CDATA[<div><p>Unless you&#8217;re reading this via RSS, you&#8217;ve already seen the new site I&#8217;ve rolled out.  I really like it and hope you do as well.  I did more than just redesign the way it looks though.  It&#8217;s more than a pretty face.</p>
<p>I spent some time trying to clean up the information on the site too.  Specifically, I shortened the <a href="/index.php/about-matt">about</a> page and really over hauled the <a href="/index.php/portfolio/">portfolio</a> page.  The portfolio is way better than it was:</p>
<p><a title="View New &#38; Old Portfolio comparison" href="javascript:GB_showImageSet(janPost, 1);"><img class="aligncenter" title="New &#38; Old Portfolio Pages" src="/images/port_post.jpg" alt="New &#38; Old Portfolio Pages" width="549" height="237" style="border: 1px SOLID #aaa;" /></a></p>
<p>I think the new page is a lot cleaner and because there&#8217;s SO much less text, it should be easier to read and understand.</p>
<p>I also thought I&#8217;d play with some APIs and get into Wordpress a but while I built the new site.  I certainly brushed up my PHP and also learned a bit about Wordpress Plugins.  I wrote a plugin like <a href="http://alexking.org/projects/wordpress" target="_blank">Twitter Tools from Alex King</a> &#8211; except mine uses my own http://mat.tc url shortener.  Obviously to do this I wrote a simple shorten API modeled after <a href="http://bit.ly/" target="_blank">bit.ly</a>&#8217;s ......</div>]]></description>
			<content:encoded><![CDATA[<p>Unless you&#8217;re reading this via RSS, you&#8217;ve already seen the new site I&#8217;ve rolled out.  I really like it and hope you do as well.  I did more than just redesign the way it looks though.  It&#8217;s more than a pretty face.</p>
<p>I spent some time trying to clean up the information on the site too.  Specifically, I shortened the <a href="/index.php/about-matt">about</a> page and really over hauled the <a href="/index.php/portfolio/">portfolio</a> page.  The portfolio is way better than it was:</p>
<p><a title="View New &amp; Old Portfolio comparison" href="javascript:GB_showImageSet(janPost, 1);"><img class="aligncenter" title="New &amp; Old Portfolio Pages" src="/images/port_post.jpg" alt="New &amp; Old Portfolio Pages" width="549" height="237" style="border: 1px SOLID #aaa;" /></a></p>
<p>I think the new page is a lot cleaner and because there&#8217;s SO much less text, it should be easier to read and understand.</p>
<p>I also thought I&#8217;d play with some APIs and get into Wordpress a but while I built the new site.  I certainly brushed up my PHP and also learned a bit about Wordpress Plugins.  I wrote a plugin like <a href="http://alexking.org/projects/wordpress" target="_blank">Twitter Tools from Alex King</a> &#8211; except mine uses my own http://mat.tc url shortener.  Obviously to do this I wrote a simple shorten API modeled after <a href="http://bit.ly/" target="_blank">bit.ly</a>&#8217;s API.  It works wonderfully.  I can tweet from the site when logged in.  Automatic new post tweets also use mat.tc now which saves me the extra steps.</p>
<p>Twitter Tools doesn&#8217;t use OAuth though, so I had to rewrite a bit of the code so Twitter would recognize my calls and show the correct &#8220;From: &#8221; line for tweets.  But that wasn&#8217;t too bad.</p>
<p>To round out the new site, I created a new logo too.  The old logo (in the image above) was just a simple play on my initials.  While exploring new ideas I came back to this &#8216;letters in my name&#8217; idea.  So the little dude is made up of letters in my name (the m, c, and 2 l&#8217;s).  I added the tie because I thought it clarified it was a person &#8211; plus the business tie-in worked (sorry).  Font is <a href="http://www.fonts.com/findfonts/detail.htm?pid=201719" target="_blank">Insignia</a>.</p>
<p>Anyway, I&#8217;m really glad the content on the site is updated.  The new design, logo and mat.tc/Twitter integration is also nice.  I threw in a little flash on the login page for fun too: <a href="/wp-login.php">check it out</a>.</p>
<p>Enjoy!<br />
<script type="text/javascript">// <![CDATA[
  var janPost = [     {'caption': 'Old Portfolio Page', 'url': '/images/port_old.jpg'},     {'caption': 'New Portfolio Page', 'url': '/images/port_new.jpg'} ];
// ]]&gt;</script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.mattchepeleff.com/index.php/2010/01/new-site-mat-tc-api-and-wordpress-plugin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sites.Local &#8211; for developers with too many local sites</title>
		<link>http://www.mattchepeleff.com/index.php/2009/12/siteslocal-for-developers-with-too-many-local-sites/</link>
		<comments>http://www.mattchepeleff.com/index.php/2009/12/siteslocal-for-developers-with-too-many-local-sites/#comments</comments>
		<pubDate>Sat, 05 Dec 2009 22:28:32 +0000</pubDate>
		<dc:creator>Matt Chepeleff</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://www.mattchepeleff.com/?p=303</guid>
		<description><![CDATA[<div><p><span>As an ASP/C# developer it&#8217;s key I work locally and save time wasted uploading files after every change to a page.  Then, when I&#8217;ve got a bunch of changes to share with a client and I want to update a staging/production environment, I can do it all at once.  Well, I resumed working on a project this afternoon that I haven&#8217;t worked on for a couple days &#8211; and I just couldn&#8217;t recall the local site address!</span></p>
<p><span>My laptop runs Vista Business and I use Internet Information Services (IIS) to run local apps.  To map the various apps and keep everything running on port 80 I take advantage of the Windows Hosts file to create custom urls for local apps.  For example, I can create an entry for clientname.localdev which enables me to setup and view a site at http://clientname.localdev/.  You can learn more about Hosts files <a href="http://en.wikipedia.org/wiki/Hosts_file">here</a> if they&#8217;re new to you.</span></p>
<p><span>Back to this morning: I couldn&#8217;t recall if I setup localdev.project, project.localdev, project.local, or local.project.  Only way to check is to open up the Hosts file and see what I had originally created.  That&#8217;s when I thought: let&#8217;s write a quick page to read all the entries in my ......</div>]]></description>
			<content:encoded><![CDATA[<p><span>As an ASP/C# developer it&#8217;s key I work locally and save time wasted uploading files after every change to a page.  Then, when I&#8217;ve got a bunch of changes to share with a client and I want to update a staging/production environment, I can do it all at once.  Well, I resumed working on a project this afternoon that I haven&#8217;t worked on for a couple days &#8211; and I just couldn&#8217;t recall the local site address!</span></p>
<p><span>My laptop runs Vista Business and I use Internet Information Services (IIS) to run local apps.  To map the various apps and keep everything running on port 80 I take advantage of the Windows Hosts file to create custom urls for local apps.  For example, I can create an entry for clientname.localdev which enables me to setup and view a site at http://clientname.localdev/.  You can learn more about Hosts files <a href="http://en.wikipedia.org/wiki/Hosts_file">here</a> if they&#8217;re new to you.</span></p>
<p><span>Back to this morning: I couldn&#8217;t recall if I setup localdev.project, project.localdev, project.local, or local.project.  Only way to check is to open up the Hosts file and see what I had originally created.  That&#8217;s when I thought: let&#8217;s write a quick page to read all the entries in my Hosts file.  So I did, and I setup sites.local as my own, local directory of entries read directly from my Hosts file.  Check it out:</span></p>
<p><span>I figured I&#8217;d create some categories to group the multiple entries I&#8217;ve got in my Hosts file &#8211; and add a quick flag for showing a category collapsed by default (more on this later).  Here&#8217;s a modified (sample) Hosts file:</span></p>
<p><span>First, let&#8217;s look at a few changes to the Hosts file itself to make all this work:</span></p>
<p><span></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
</pre></td><td class="code"><pre class="winbatch" style="font-family:monospace;"><span style="color: #66cc66;">#</span> Copyright <span style="color: #66cc66;">&#40;</span>c<span style="color: #66cc66;">&#41;</span> <span style="color: #cc66cc;">1993</span><span style="color: #66cc66;">-</span><span style="color: #cc66cc;">2006</span> Microsoft Corp.
<span style="color: #66cc66;">#</span>
<span style="color: #66cc66;">#</span> This is a sample HOSTS file used <span style="color: #800080;">by</span> Microsoft TCP<span style="color: #66cc66;">/</span>IP <span style="color: #800080;">for</span> Windows.
<span style="color: #66cc66;">#</span>
<span style="color: #66cc66;">#</span> This file contains the mappings of IP addresses <span style="color: #800080;">to</span> host names. Each
<span style="color: #66cc66;">#</span> entry should be kept <span style="color: #0080FF; font-weight: bold;">on</span> an individual line. The IP address should
<span style="color: #66cc66;">#</span> be placed <span style="color: #800080;">in</span> the first column followed <span style="color: #800080;">by</span> the corresponding host name.
<span style="color: #66cc66;">#</span> The IP address and the host name should be separated <span style="color: #800080;">by</span> at least one
<span style="color: #66cc66;">#</span> space.
<span style="color: #66cc66;">#</span>
<span style="color: #66cc66;">#</span> Additionally, comments <span style="color: #66cc66;">&#40;</span>such as these<span style="color: #66cc66;">&#41;</span> may be inserted <span style="color: #0080FF; font-weight: bold;">on</span> individual
<span style="color: #66cc66;">#</span> lines or following the machine name denoted <span style="color: #800080;">by</span> a <span style="color: #ff0000;">'#'</span> symbol.
<span style="color: #66cc66;">#</span>
<span style="color: #66cc66;">#</span> <span style="color: #800080;">For</span> example<span style="color: #FF1010; font-weight: bold;">:</span>
<span style="color: #66cc66;">#</span>
<span style="color: #66cc66;">#</span>      102.54.94.97     rhino.acme.com          <span style="color: #66cc66;">#</span> source <span style="color: #0080FF; font-weight: bold;">server</span>
<span style="color: #66cc66;">#</span>       38.25.63.10     x.acme.com              <span style="color: #66cc66;">#</span> x client host
&nbsp;
127.0.0.1       localhost	<span style="color: #66cc66;">#</span>ExcludeFromSites.Local
<span style="color: #FF1010; font-weight: bold;">::1             localhost	#ExcludeFromSites.Local</span>
&nbsp;
<span style="color: #66cc66;">#</span>Sites.Local.Category<span style="color: #FF1010; font-weight: bold;">: New Projects Category#</span>
127.0.0.1       project1.local
127.0.0.1       project2.dev
127.0.0.1       anotherclient.devel
127.0.0.1       project3.local
&nbsp;
<span style="color: #66cc66;">#</span>Sites.Local.Category<span style="color: #FF1010; font-weight: bold;">: Other Category Here#</span>
127.0.0.1       project4.local
127.0.0.1       project5.dev
127.0.0.1       project6.local
&nbsp;
<span style="color: #66cc66;">#</span>Sites.Local.Category<span style="color: #FF1010; font-weight: bold;">: Archived/Past Por {start:collapsed}#</span>
127.0.0.1       project7.local
127.0.0.1       project8.dev
127.0.0.1       client23.devel
127.0.0.1       project9.local
127.0.0.1       project10.local
127.0.0.1       project11.dev
127.0.0.1       clientname.devel
127.0.0.1       project12.local</pre></td></tr></table></div>

<p></span></p>
<p><span>This obviously is not my Hosts file &#8211; I created a sample file for demo purposes.  But either way, there are a couple things to note here &#8211; most of which will make sense as you look at the upcoming .aspx and code behind:
<ul>
<li>Adding &#8220;#ExcludeFromSites.Local&#8221; to the end of the line will (you guessed) prevent the line&#8217;s display on our page</li>
<li>You can group entries by adding &#8220;#Sites.Local.Category: <em>categoryname</em># to a line above that group, where <em>categoryname </em>is some text you&#8217;d like to refer to this category by</li>
<li>You can &#8220;{start:collapsed}&#8221; to a group name to display this group collapsed initially (each group can be collapsed/expanded by clicking the group name</li>
</ul>
<p>Now onto the code &#8211; I made comments throughout the code behind to make things easy to follow.  The code could certainly be simplified, but for the sake of clarity I expanded some of it.</span></p>
<p><span>First, the .aspx page:</span></p>
<p><span></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
</pre></td><td class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #008000;">&lt;%</span>@ Page Language<span style="color: #008000;">=</span><span style="color: #666666;">&quot;C#&quot;</span> AutoEventWireup<span style="color: #008000;">=</span><span style="color: #666666;">&quot;true&quot;</span> CodeFile<span style="color: #008000;">=</span><span style="color: #666666;">&quot;Default.aspx.cs&quot;</span> 
<span style="color: #008000;">&amp;</span>nbsp<span style="color: #008000;">;&amp;</span>nbsp<span style="color: #008000;">;&amp;</span>nbsp<span style="color: #008000;">;&amp;</span>nbsp<span style="color: #008000;">;&amp;</span>nbsp<span style="color: #008000;">;&amp;</span>nbsp<span style="color: #008000;">;&amp;</span>nbsp<span style="color: #008000;">;&amp;</span>nbsp<span style="color: #008000;">;</span>Inherits<span style="color: #008000;">=</span><span style="color: #666666;">&quot;siteslocal_default&quot;</span> <span style="color: #008000;">%&gt;</span>
&nbsp;
<span style="color: #008000;">&lt;!</span>DOCTYPE html <span style="color: #0600FF;">PUBLIC</span> <span style="color: #666666;">&quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;</span>
      <span style="color: #666666;">&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;</span><span style="color: #008000;">&gt;</span>
&nbsp;
<span style="color: #008000;">&lt;</span>html xmlns<span style="color: #008000;">=</span><span style="color: #666666;">&quot;http://www.w3.org/1999/xhtml&quot;</span> <span style="color: #008000;">&gt;</span>
<span style="color: #008000;">&lt;</span>head runat<span style="color: #008000;">=</span><span style="color: #666666;">&quot;server&quot;</span><span style="color: #008000;">&gt;</span>
    <span style="color: #008000;">&lt;</span>title<span style="color: #008000;">&gt;</span>Local Site Addresses<span style="color: #008000;">&lt;/</span>title<span style="color: #008000;">&gt;</span>
    <span style="color: #008000;">&lt;</span>style type<span style="color: #008000;">=</span><span style="color: #666666;">&quot;text/css&quot;</span><span style="color: #008000;">&gt;</span>
        <span style="color: #008000;">*</span> <span style="color: #000000;">&#123;</span>
            font<span style="color: #008000;">-</span>family<span style="color: #008000;">:</span>Arial<span style="color: #008000;">;</span>
            font<span style="color: #008000;">-</span>size<span style="color: #008000;">:</span>13px<span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
        body <span style="color: #000000;">&#123;</span>
            background<span style="color: #008000;">-</span>color<span style="color: #008000;">:</span><span style="color: #008080;">#dfd;</span>
        <span style="color: #000000;">&#125;</span>
        div<span style="color: #008080;">#centercontent {</span>
            width<span style="color: #008000;">:</span> 800px<span style="color: #008000;">;</span>
            height<span style="color: #008000;">:</span> 500px<span style="color: #008000;">;</span>
            text<span style="color: #008000;">-</span>align<span style="color: #008000;">:</span> center<span style="color: #008000;">;</span>
            position<span style="color: #008000;">:</span> absolute<span style="color: #008000;">;</span>
            left<span style="color: #008000;">:</span> <span style="color: #FF0000;">50</span><span style="color: #008000;">%;</span>
            top<span style="color: #008000;">:</span> <span style="color: #FF0000;">50</span><span style="color: #008000;">%;</span>
            margin<span style="color: #008000;">-</span>left<span style="color: #008000;">:</span> <span style="color: #008000;">-</span>400px<span style="color: #008000;">;</span>
            margin<span style="color: #008000;">-</span>top<span style="color: #008000;">:</span> <span style="color: #008000;">-</span>250px<span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
        div<span style="color: #008080;">#header {</span>
            text<span style="color: #008000;">-</span>align<span style="color: #008000;">:</span>left<span style="color: #008000;">;</span>
            font<span style="color: #008000;">-</span>size<span style="color: #008000;">:</span>23px<span style="color: #008000;">;</span>
            font<span style="color: #008000;">-</span>weight<span style="color: #008000;">:</span>bold<span style="color: #008000;">;</span>
            height<span style="color: #008000;">:</span>30px<span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
        div<span style="color: #008080;">#content {</span>
            border<span style="color: #008000;">:</span> 1px solid <span style="color: #008080;">#000;</span>
            padding<span style="color: #008000;">:</span> 30px<span style="color: #008000;">;</span>
            text<span style="color: #008000;">-</span>align<span style="color: #008000;">:</span>left<span style="color: #008000;">;</span>
            height<span style="color: #008000;">:</span>360px<span style="color: #008000;">;</span>
            background<span style="color: #008000;">-</span>color<span style="color: #008000;">:</span><span style="color: #008080;">#fff;</span>
            overflow<span style="color: #008000;">-</span>y<span style="color: #008000;">:</span>scroll<span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
        div<span style="color: #008080;">#footer {</span>
            text<span style="color: #008000;">-</span>align<span style="color: #008000;">:</span>left<span style="color: #008000;">;</span>
            font<span style="color: #008000;">-</span>size<span style="color: #008000;">:</span>12px<span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
        div.<span style="color: #0000FF;">category</span> <span style="color: #000000;">&#123;</span>
            margin<span style="color: #008000;">-</span>bottom<span style="color: #008000;">:</span>15px<span style="color: #008000;">;</span>
            margin<span style="color: #008000;">-</span>left<span style="color: #008000;">:</span>10px<span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
    <span style="color: #008000;">&lt;/</span>style<span style="color: #008000;">&gt;</span>
<span style="color: #008000;">&lt;/</span>head<span style="color: #008000;">&gt;</span>
<span style="color: #008000;">&lt;</span>body<span style="color: #008000;">&gt;</span>
    <span style="color: #008000;">&lt;</span>form id<span style="color: #008000;">=</span><span style="color: #666666;">&quot;form1&quot;</span> runat<span style="color: #008000;">=</span><span style="color: #666666;">&quot;server&quot;</span><span style="color: #008000;">&gt;</span>
    <span style="color: #008000;">&lt;</span>div id<span style="color: #008000;">=</span><span style="color: #666666;">&quot;centercontent&quot;</span><span style="color: #008000;">&gt;</span>
        <span style="color: #008000;">&lt;</span>div id<span style="color: #008000;">=</span><span style="color: #666666;">&quot;header&quot;</span><span style="color: #008000;">&gt;</span>Local Site Addresses<span style="color: #008000;">&lt;/</span>div<span style="color: #008000;">&gt;</span>
        <span style="color: #008000;">&lt;</span>div id<span style="color: #008000;">=</span><span style="color: #666666;">&quot;content&quot;</span><span style="color: #008000;">&gt;</span>
            <span style="color: #008000;">&lt;</span>asp<span style="color: #008000;">:</span>Literal id<span style="color: #008000;">=</span><span style="color: #666666;">&quot;litHosts&quot;</span> runat<span style="color: #008000;">=</span><span style="color: #666666;">&quot;server&quot;</span><span style="color: #008000;">&gt;&lt;/</span>asp<span style="color: #008000;">:</span>Literal<span style="color: #008000;">&gt;</span>
        <span style="color: #008000;">&lt;/</span>div<span style="color: #008000;">&gt;</span>
        <span style="color: #008000;">&lt;</span>div id<span style="color: #008000;">=</span><span style="color: #666666;">&quot;footer&quot;</span><span style="color: #008000;">&gt;</span>The contents of <span style="color: #0600FF;">this</span> page are being read directly
             from the hosts file <span style="color: #0600FF;">in</span> C<span style="color: #008000;">:</span>WindowsSystem32driversetc<span style="color: #008000;">&lt;/</span>div<span style="color: #008000;">&gt;</span>
    <span style="color: #008000;">&lt;/</span>div<span style="color: #008000;">&gt;</span>
    <span style="color: #008000;">&lt;/</span>form<span style="color: #008000;">&gt;</span>
<span style="color: #008000;">&lt;/</span>body<span style="color: #008000;">&gt;</span>
<span style="color: #008000;">&lt;/</span>html<span style="color: #008000;">&gt;</span></pre></td></tr></table></div>

<p></span></p>
<p><span>And for the meat of the page, here&#8217;s the code behind written in c#:</span></p>
<p><span></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
</pre></td><td class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">using</span> <span style="color: #008080;">System.Web</span><span style="color: #008000;">;</span>
<span style="color: #0600FF;">using</span> <span style="color: #008080;">System.Web.UI</span><span style="color: #008000;">;</span>
<span style="color: #0600FF;">using</span> <span style="color: #008080;">System.IO</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #0600FF;">public</span> <span style="color: #0600FF;">partial</span> <span style="color: #FF0000;">class</span> siteslocal_default <span style="color: #008000;">:</span> <span style="color: #000000;">System.<span style="color: #0000FF;">Web</span>.<span style="color: #0000FF;">UI</span></span>.<span style="color: #0000FF;">Page</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #0600FF;">protected</span> <span style="color: #0600FF;">void</span> Page_Load<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">object</span> sender, EventArgs e<span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
        StreamReader reader <span style="color: #008000;">=</span> File.<span style="color: #0000FF;">OpenText</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">@&quot;C:WindowsSystem32driversetchosts&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #FF0000;">string</span> line <span style="color: #008000;">=</span> <span style="color: #FF0000;">string</span>.<span style="color: #0000FF;">Empty</span><span style="color: #008000;">;</span>
        <span style="color: #0600FF;">while</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>line <span style="color: #008000;">=</span> reader.<span style="color: #0000FF;">ReadLine</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">!=</span> <span style="color: #0600FF;">null</span><span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #008000;">!</span>line.<span style="color: #0000FF;">StartsWith</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;# &quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">&amp;</span>amp<span style="color: #008000;">;&amp;</span>amp<span style="color: #008000;">;</span>
                <span style="color: #008000;">!</span>line.<span style="color: #0000FF;">StartsWith</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot; &quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">&amp;</span>amp<span style="color: #008000;">;&amp;</span>amp<span style="color: #008000;">;</span>
                line <span style="color: #008000;">!=</span> <span style="color: #666666;">&quot;#&quot;</span> <span style="color: #008000;">&amp;</span>amp<span style="color: #008000;">;&amp;</span>amp<span style="color: #008000;">;</span>
                line <span style="color: #008000;">!=</span> <span style="color: #666666;">&quot;&quot;</span> <span style="color: #008000;">&amp;</span>amp<span style="color: #008000;">;&amp;</span>amp<span style="color: #008000;">;</span>
                <span style="color: #008000;">!</span>line.<span style="color: #0000FF;">EndsWith</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;#ExcludeFromSites.Local&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
            <span style="color: #000000;">&#123;</span>
                <span style="color: #FF0000;">bool</span> show_collapsed <span style="color: #008000;">=</span> false<span style="color: #008000;">;</span>
                <span style="color: #FF0000;">string</span> showhidecode <span style="color: #008000;">=</span> <span style="color: #FF0000;">string</span>.<span style="color: #0000FF;">Empty</span><span style="color: #008000;">;</span>
                <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>line.<span style="color: #0000FF;">StartsWith</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;#&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
                <span style="color: #000000;">&#123;</span>
                    <span style="color: #008080; font-style: italic;">/******* Append the HTML for the start of a new category *******/</span>
                    <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>litHosts.<span style="color: #0000FF;">Text</span> <span style="color: #008000;">!=</span> <span style="color: #666666;">&quot;&quot;</span><span style="color: #000000;">&#41;</span>
                        litHosts.<span style="color: #0000FF;">Text</span> <span style="color: #008000;">+=</span> <span style="color: #666666;">&quot;&quot;</span><span style="color: #008000;">;</span> <span style="color: #008080; font-style: italic;">//only append if we're not on the first category</span>
&nbsp;
                    <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>line.<span style="color: #0000FF;">Contains</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;{start:collapsed}&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
                        show_collapsed <span style="color: #008000;">=</span> true<span style="color: #008000;">;</span>
&nbsp;
                    <span style="color: #FF0000;">string</span> catText <span style="color: #008000;">=</span> line<span style="color: #008000;">;</span>
                    catText <span style="color: #008000;">=</span> catText.<span style="color: #0000FF;">Replace</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot; &quot;</span>, <span style="color: #666666;">&quot;&quot;</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">Replace</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;t&quot;</span>, <span style="color: #666666;">&quot;&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>     <span style="color: #008080; font-style: italic;">//remove spaces and tabs</span>
                    catText <span style="color: #008000;">=</span> catText.<span style="color: #0000FF;">Replace</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;{start:collapsed}&quot;</span>, <span style="color: #666666;">&quot;&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>       <span style="color: #008080; font-style: italic;">//remove from display</span>
                    catText <span style="color: #008000;">=</span> catText.<span style="color: #0000FF;">Replace</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;Sites.Local.Category:&quot;</span>, <span style="color: #666666;">&quot;&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>   <span style="color: #008080; font-style: italic;">//remove category prefix</span>
                    catText <span style="color: #008000;">=</span> catText.<span style="color: #0000FF;">Replace</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;#&quot;</span>, <span style="color: #666666;">&quot;&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>                       <span style="color: #008080; font-style: italic;">//remove any stray #'s</span>
&nbsp;
                    <span style="color: #008080; font-style: italic;">//prep the javascript onclick code and div id</span>
                    <span style="color: #FF0000;">string</span> id <span style="color: #008000;">=</span> catText.<span style="color: #0000FF;">ToLower</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
                    <span style="color: #FF0000;">string</span> js <span style="color: #008000;">=</span> <span style="color: #FF0000;">string</span>.<span style="color: #0000FF;">Format</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;document.getElementById('{0}').style.display&quot;</span>,id<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
                    showhidecode <span style="color: #008000;">=</span> _
                       <span style="color: #666666;">@&quot;onclick=&quot;</span><span style="color: #666666;">&quot;if({0}=='block'){{0}='none';}else{{0}='block';}&quot;</span><span style="color: #666666;">&quot;&quot;</span>.<span style="color: #0000FF;">Replace</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;{0}&quot;</span>, js<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
                    <span style="color: #008080; font-style: italic;">//append the &amp;lt;div&amp;gt; for this category's name</span>
                    litHosts.<span style="color: #0000FF;">Text</span> <span style="color: #008000;">+=</span> <span style="color: #FF0000;">string</span>.<span style="color: #0000FF;">Format</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">@&quot;&amp;lt;div style=&quot;</span><span style="color: #666666;">&quot;cursor:pointer;&quot;</span><span style="color: #666666;">&quot; {0}&amp;gt; _
                    &amp;lt;b&amp;gt;{1}&amp;lt;/b&amp;gt;&amp;lt;/div&amp;gt;&quot;</span>, showhidecode, catText<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
                    <span style="color: #008080; font-style: italic;">//append the &amp;lt;div&amp;gt; opening tag for this category</span>
                    litHosts.<span style="color: #0000FF;">Text</span> <span style="color: #008000;">+=</span> <span style="color: #FF0000;">string</span>.<span style="color: #0000FF;">Format</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">@&quot;&amp;lt;div id=&quot;</span><span style="color: #666666;">&quot;{0}&quot;</span><span style="color: #666666;">&quot; class=&quot;</span><span style="color: #666666;">&quot;category&quot;</span><span style="color: #666666;">&quot; _
                         style=&quot;</span><span style="color: #666666;">&quot;display:{1};&quot;</span><span style="color: #666666;">&quot;&amp;gt;&quot;</span>, id, show_collapsed <span style="color: #008000;">?</span> <span style="color: #666666;">&quot;none&quot;</span> <span style="color: #008000;">:</span> <span style="color: #666666;">&quot;block&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
                <span style="color: #000000;">&#125;</span>
                <span style="color: #0600FF;">else</span>
                <span style="color: #000000;">&#123;</span>
                    <span style="color: #008080; font-style: italic;">/******* Append the HTML for each item in the current category *******/</span>
                    <span style="color: #008080; font-style: italic;">//first let's isolate the host name (assumes we don't need to display the IPs)</span>
                    <span style="color: #008080; font-style: italic;">//so...let's the find the index of the first space or tab</span>
                    <span style="color: #FF0000;">string</span> url <span style="color: #008000;">=</span> <span style="color: #FF0000;">string</span>.<span style="color: #0000FF;">Empty</span><span style="color: #008000;">;</span>
                    line <span style="color: #008000;">=</span> line.<span style="color: #0000FF;">Trim</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
                    <span style="color: #FF0000;">int</span> spacer_location <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span>
                    spacer_location <span style="color: #008000;">=</span> line.<span style="color: #0000FF;">IndexOf</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">' '</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
                    <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>spacer_location <span style="color: #008000;">==</span> <span style="color: #008000;">-</span><span style="color: #FF0000;">1</span><span style="color: #000000;">&#41;</span>
                        spacer_location <span style="color: #008000;">=</span> line.<span style="color: #0000FF;">IndexOf</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;t&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
                    <span style="color: #008080; font-style: italic;">//display from the spacer to the end</span>
                    url <span style="color: #008000;">=</span> line.<span style="color: #0000FF;">Substring</span><span style="color: #000000;">&#40;</span>spacer_location, line.<span style="color: #0000FF;">Length</span> <span style="color: #008000;">-</span> spacer_location<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
                    url <span style="color: #008000;">=</span> url.<span style="color: #0000FF;">Replace</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot; &quot;</span>, <span style="color: #666666;">&quot;&quot;</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">Replace</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;t&quot;</span>, <span style="color: #666666;">&quot;&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span> <span style="color: #008080; font-style: italic;">//remove any spaces or tabs</span>
&nbsp;
                    <span style="color: #008080; font-style: italic;">//write out this line</span>
                    litHosts.<span style="color: #0000FF;">Text</span> <span style="color: #008000;">+=</span> <span style="color: #FF0000;">string</span>.<span style="color: #0000FF;">Format</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">@&quot;&amp;lt;a href=&quot;</span><span style="color: #666666;">&quot;http://{0}/&quot;</span><span style="color: #666666;">&quot;&amp;gt;{0}&amp;lt;/a&amp;gt;&amp;lt;br /&amp;gt;&quot;</span>, url<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
                <span style="color: #000000;">&#125;</span>
            <span style="color: #000000;">&#125;</span>
        <span style="color: #000000;">&#125;</span>
        litHosts.<span style="color: #0000FF;">Text</span> <span style="color: #008000;">+=</span> <span style="color: #666666;">&quot;&quot;</span><span style="color: #008000;">;</span> <span style="color: #008080; font-style: italic;">//close out the last div</span>
        reader.<span style="color: #0000FF;">Dispose</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p></span></p>
<p><span>The only other things to note are:</span></p>
<ul>
<li>I setup this page to run at http://sites.local and site this as my home page in Chrome &#8211; in IIS I changed the anonymous user to my own username (to ensure the code has permission to access the file)</li>
<li>Be sure to not to start an entry in your Hosts file with a Tab &#8211; the code allows preceeding spaced, but would need to be changed to allow preceeding Tabs</li>
</ul>
<p><span>That&#8217;s it, hope you find this useful and a bit of a timesaver too.  Only took about 30 minutes to pull together, and I think you ought to be able to set it up in less time than that.</span></p>
<p><span>Happy coding!</span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.mattchepeleff.com/index.php/2009/12/siteslocal-for-developers-with-too-many-local-sites/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
