<?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>Many Niches &#187; N00b Notes</title>
	<atom:link href="http://www.manyniches.com/category/n00b-notes/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.manyniches.com</link>
	<description>Jack of All Trades, Master of Some</description>
	<lastBuildDate>Mon, 14 Nov 2011 21:12:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>What Do You Call One Search Result From StackOverflow?</title>
		<link>http://www.manyniches.com/n00b-notes/what-do-you-call-one-search-result-from-stackoverflow/</link>
		<comments>http://www.manyniches.com/n00b-notes/what-do-you-call-one-search-result-from-stackoverflow/#comments</comments>
		<pubDate>Tue, 16 Mar 2010 23:01:56 +0000</pubDate>
		<dc:creator>Brandon Watson</dc:creator>
				<category><![CDATA[N00b Notes]]></category>
		<category><![CDATA[301 redirect]]></category>
		<category><![CDATA[URL shortener]]></category>
		<category><![CDATA[windows phone 7]]></category>

		<guid isPermaLink="false">http://www.manyniches.com/n00b-notes/what-do-you-call-one-search-result-from-stackoverflow/</guid>
		<description><![CDATA[Windows Phone 7 301 Redirect Bug I checked with the Windows Phone 7 team before putting this post out, and got the OK to write about it.&#160; I hit this bug when building out my FriendLinks Windows Phone 7 application, and was surprised to find it was a bona fide bug and not a problem [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 5px; margin-right: 5px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.manyniches.com%2Fn00b-notes%2Fwhat-do-you-call-one-search-result-from-stackoverflow%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.manyniches.com%2Fn00b-notes%2Fwhat-do-you-call-one-search-result-from-stackoverflow%2F&amp;source=BrandonWatson&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<h1>Windows Phone 7 301 Redirect Bug</h1>
<p>I checked with the Windows Phone 7 team before putting this post out, and got the OK to write about it.&#160; I hit this bug when building out my <a href="http://www.manyniches.com/n00b-notes/windows-phone-7-series-developer-experience">FriendLinks Windows Phone 7 application</a>, and was surprised to find it was a bona fide bug and not a problem with my coding skills.&#160; If there was a default value in the constructor for any new project I start, it would look something like:</p>
<pre class="csharpcode">codingErrorResponsibilty == <span class="kwrd">this</span>.programmerName;</pre>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>&#160;</p>
<p>In any event, here’s the cruxt of the bug.&#160; If you are using HttpWebRequest developing on Windows Phone 7, and you get a 301 redirect returned from the web server, and that web server sets a cookie, the current build (as of 03/16/10 at Mix10) of Windows Phone 7 will throw an exception.</p>
<p>In the case of my applications, I was trying to determine the title of the page as defined by the “&lt;title&gt;&lt;/title&gt;” tags for a given URL.&#160; The function I wrote for this was:</p>
<p><span id="more-386"></span></p>
<pre class="csharpcode"><span class="kwrd">try</span>
{
    WebResponse response = ((HttpWebRequest)result.AsyncState)</pre>
<pre class="csharpcode">                            .EndGetResponse(result);
    StreamReader reader = <span class="kwrd">new</span> StreamReader(response.GetResponseStream());
    <span class="kwrd">string</span> responseString = reader.ReadToEnd();
    <span class="kwrd">string</span> regex = <span class="str">@&quot;(?&lt;=&lt;title.*&gt;)([\s\S]*)(?=&lt;/title&gt;)&quot;</span>;

    <span class="kwrd">if</span> (<span class="kwrd">new</span> List&lt;<span class="kwrd">string</span>&gt;(response.Headers.AllKeys).Contains(<span class="str">&quot;Content-Type&quot;</span>))
    {
        <span class="kwrd">if</span> (response.Headers[<span class="str">&quot;Content-Type&quot;</span>].StartsWith(<span class="str">&quot;text/html&quot;</span>))
        {
            Regex ex = <span class="kwrd">new</span> Regex(regex, RegexOptions.IgnoreCase);

            selectedUrlTitle = ex.Match(responseString).Value.Trim();

            <span class="kwrd">if</span> (String.IsNullOrEmpty(selectedUrlTitle))
            {
                selectedUrlTitle = <span class="str">&quot;No title for page&quot;</span>;
            }
        }

    }
    </pre>
<pre class="csharpcode">    UrlTitleRequestCompleted(<span class="kwrd">this</span>, EventArgs.Empty);
}</pre>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>For some URLs this was throwing the most elusive of all exceptions: CookieException.&#160; Behold, I present to you a StackOverflowWhack! [note: a nod to <a href="http://en.wikipedia.org/wiki/Googlewhack">GoogleWhacks</a>]&#160; There should really be a better name for that.</p>
<p><a href="http://www.manyniches.com/wp-content/uploads/2010/03/image3.png"><img style="border-bottom: 0px; border-left: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px" title="image" border="0" alt="image" src="http://www.manyniches.com/wp-content/uploads/2010/03/image_thumb3.png" width="504" height="171" /></a> </p>
<p>There is only one response for this search query at StackOverflow.&#160; Interestingly enough, when I first hit this bug, there were no questions – this one was asked in the last week.</p>
<p>The debug information from Visual Studio was even less useful.&#160; It was telling me that the cookie was too big.&#160; A little searching revealed that this exception is thrown when you try to set a cookie larger than MaxCookieSize for a CookieContainer.&#160; That value <a href="http://msdn.microsoft.com/en-us/library/system.net.cookiecontainer.maxcookiesize(VS.96).aspx">cannot be changed in Silverlight</a>, and since I don’t control the remote web servers, I can’t control the cookie coming back.&#160; Worse, whether or not the cookie was being set on the 301 redirects varied from domain to domain.&#160; Some set it, some didn’t.</p>
<p>In using <a href="http://www.fiddler2.com/fiddler2/">Fiddler2</a> to debug this problem, here is what a redirect looks like that won’t throw the CookieException:</p>
<pre class="csharpcode">HTTP/1.1 301 Moved Permanently
Proxy-Connection: Keep-Alive
Connection: Keep-Alive
Transfer-Encoding: chunked
Via: 1.1 RED-PRXY-21
Date: Wed, 03 Mar 2010 02:55:15 GMT
Location: http:<span class="rem">//blogs.bnet.com/career-advice/?p=101</span>
Content-Type: text/html; charset=UTF-8
Server: Apache
Set-Cookie: supr=supr301; path=/; domain=.su.pr
Vary: Accept-Encoding</pre>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>&#160;</p>
<p>In this case, su.pr didn’t try to set the cookie.&#160; And here is a 301 redirect that tries to set a cookie:</p>
<pre class="csharpcode">HTTP/1.1 301 Moved
Proxy-Connection: Keep-Alive
Connection: Keep-Alive
Content-Length: 381
Via: 1.1 RED-PRXY-21
Date: Wed, 03 Mar 2010 02:57:15 GMT
Location: <a href="http://www.allfacebook.com/2010/03/facebook-developers-see">http:<span class="rem">//www.allfacebook.com/2010/03/facebook-developers-see</a>-</span></pre>
<pre class="csharpcode"><span class="rem">               dramatic-drop-in-traffic-following-removal-of-notifications/</span>
Content-Type: text/html; charset=utf-8
Server: nginx/0.7.42
Set-Cookie: _bit=4b8dd00b-0013c-01992-b5a08fa8;domain=.bit.ly;</pre>
<pre class="csharpcode">                expires=Sun Aug 29 22:57:15 2010;path=/; HttpOnly
MIME-Version: 1.0</pre>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>In this case, bit.ly is in fact trying to set a cookie.&#160; What helped lead me down the path of figuring this out was a short.to link that forwarded to a bit.ly link.&#160; Here’s the chain of raw headers:</p>
<pre class="csharpcode">HTTP/1.1 301 Moved Permanently
Proxy-Connection: Keep-Alive
Connection: Keep-Alive
Content-Length: 0
Via: 1.1 RED-PRXY-21
Expires: Fri, 01 Jan 1990 00:00:00 GMT
Date: Wed, 03 Mar 2010 02:58:43 GMT
Location: http:<span class="rem">//bit.ly/8ZyVoz</span>
Content-Type: text/html; charset=utf-8
Server: Google Frontend
Cache-Control: no-cache
X-XSS-Protection: 0

HTTP/1.1 301 Moved
Proxy-Connection: Keep-Alive
Connection: Keep-Alive
Content-Length: 312
Via: 1.1 RED-PRXY-21
Date: Wed, 03 Mar 2010 02:58:44 GMT
Location: http:<span class="rem">//news.cnet.com/8301-13578_3-10462563-38.html</span>
Content-Type: text/html; charset=utf-8
Server: nginx/0.7.42
Set-Cookie: _bit=4b8dd064-000f6-0198d-b5a08fa8;domain=.bit.ly;</pre>
<pre class="csharpcode">                expires=Sun Aug 29 22:58:44 2010;path=/; HttpOnly
MIME-Version: 1.0</pre>
<p>&#160;</p>
<p>As you can see here, the first header revealed a 301 to a bit.ly URL, which then tried to redirect to a news.com article.&#160; Some other offenders of this cookie setting on 301 redirects are FourSquare and TechCrunch.&#160; Mind you, this isn’t a bug in their 301 redirect, it’s a bug in how Windows Phone 7 handles the redirect.</p>
<p>I ultimately had to abandon this path to get the page title because once that CookieException is thrown, there is no data in the exception that allows you to get access to the header.&#160; The exception is thrown when the WebResponse object is being set to the result of reading to the end of the asynch response.&#160; The CookieException itself doesn’t reveal any of the 301 redirect information, so recovering from this exception is next to impossible, except to abandon trying to get the URL title.</p>
<p>For my specific app, I needed to get that title information, and since the vast majority of links coming through Twitter were bit.ly, I needed another way.&#160; Mercifully, TechMeme reveals this information through their API.</p>
<p>So there you go – if you are getting a 301 redirect in a HttpWebRequest, and your code is throwing a CookieException, now you know why.&#160; This is a filed bug and should be fixed, but given the amount of excitement around Windows Phone 7 development right now, I wanted to try and save people pain and suffering.&#160; It’s better that only one of us lose hair.</p>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
]]></content:encoded>
			<wfw:commentRss>http://www.manyniches.com/n00b-notes/what-do-you-call-one-search-result-from-stackoverflow/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Windows Phone 7 Series Developer Experience</title>
		<link>http://www.manyniches.com/n00b-notes/windows-phone-7-series-developer-experience/</link>
		<comments>http://www.manyniches.com/n00b-notes/windows-phone-7-series-developer-experience/#comments</comments>
		<pubDate>Mon, 15 Mar 2010 16:17:00 +0000</pubDate>
		<dc:creator>Brandon Watson</dc:creator>
				<category><![CDATA[N00b Notes]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[n00bnotes]]></category>
		<category><![CDATA[silverlight]]></category>
		<category><![CDATA[windows phone 7]]></category>
		<category><![CDATA[WP7]]></category>

		<guid isPermaLink="false">http://www.manyniches.com/n00b-notes/windows-phone-7-series-developer-experience/</guid>
		<description><![CDATA[Today at Mix10, Microsoft released the developer tools for Windows Phone 7 Series.&#160; I’m excited about seeing what apps will get built now that there is general availability of the Windows Phone dev tools.&#160; That’s general availability, as in for everyone! Charlie Kindel (if you aren’t, you really should follow him) was nice enough to [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 5px; margin-right: 5px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.manyniches.com%2Fn00b-notes%2Fwindows-phone-7-series-developer-experience%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.manyniches.com%2Fn00b-notes%2Fwindows-phone-7-series-developer-experience%2F&amp;source=BrandonWatson&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p><a href="http://www.manyniches.com/wp-content/uploads/2010/03/image.png"><img style="border-right-width: 0px; margin: 0px 5px 0px 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" align="left" src="http://www.manyniches.com/wp-content/uploads/2010/03/image_thumb.png" width="164" height="318" /></a>Today at <a href="http://live.visitmix.com/">Mix10</a>, Microsoft released the developer tools for <a href="http://www.microsoft.com/express/phone">Windows Phone 7 Series</a>.&#160; I’m excited about seeing what apps will get built now that there is <a href="http://www.microsoft.com/express/phone">general availability of the Windows Phone dev tools</a>.&#160; That’s general availability, as in for everyone!</p>
<p><a href="http://blogs.msdn.com/ckindel">Charlie Kindel</a> (if you aren’t, <a href="http://www.twitter.com/ckindel">you really should follow him</a>) was nice enough to get me access to the tools about 3 weeks ago, despite the fact that he and his team have had plenty on their plate since going public with WP7.&#160; I have spent some time in the last few winks building and tinkering.</p>
<p>A little background on my dev skills.&#160; I can write basic applications, and have been known to favor Python when trying out new ideas.&#160; I have dabbled a bit with our ASP.NET MVC (<a href="http://weblogs.asp.net/scottgu/archive/2010/03/11/asp-net-mvc-2-released.aspx">MVC v2 just released</a> – way to go guys!!) and taught myself enough C# to be dangerous.&#160; What coding I do, I do for fun and in my free time.&#160; I call it my nocturnal nerdiness, and have been logging some of my projects using the <a href="http://www.manyniches.com/category/n00b-notes/">n00bnotes tag</a>.&#160; Prior to 3 weeks ago, I had never written one line of Silverlight (or WPF for that matter) code, nor any XAML.&#160; I was really excited to have the opportunity to build apps for this mobile platform, as I once tried to get along with iPhone development, and while it’s clear that Apple has created tools that developers seem to love, I couldn’t get along with ObjectiveC.&#160; That’s a me issue, and not a statement about ObjectiveC.&#160; I get along famously with Python, but me and Ruby are not friends.&#160; That’s just the way my brain works.</p>
<p><a href="http://www.manyniches.com/wp-content/uploads/2010/03/image1.png"><img style="border-right-width: 0px; margin: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" align="right" src="http://www.manyniches.com/wp-content/uploads/2010/03/image_thumb1.png" width="164" height="324" /></a>With that as a preamble, I wanted to share what I have created in just the last 3 weeks, working largely in what spare time I could find when not doing my day job or dealing with an recalcitrant 8 month old girl who refuses to sleep.&#160; The main thing I want people to take away from this is that it in <strong>incredibly</strong> <strong>easy to built apps for Windows Phone 7</strong>.&#160; If I can figure it out, anyone can.&#160; The team has delivered a great development experience built on top of Visual Studio Express.&#160; When you fire up the development environment, everything you need is there and you are ready to go.&#160; It was a pretty painless experience to get the environment up and running, and it includes templates for Silverlight apps as well as XNA games.&#160; While I have only been able to deploy to an actual phone once, the emulator felt like a software version of the phone.</p>
<p>Over the next few days of Mix10, I am going to put up a few posts about my experiences with the development tools, highlighting some of the blockers I hit, how I solved them, and for some of them, how I should have solved them, which I eventually fixed during code refactoring.</p>
<p>In the meantime, I wanted to share a link to the current version of the code.&#160; This is my <a href="http://www.manyniches.com/wp-content/uploads/2010/03/FriendLinks1.zip">FriendLinks application, built for Windows Phone 7</a> [UPDATE: 3/24/10 – oh the joy of forgetting to remove commented code with your twitter pass.&#160; Ooops…code updated.]&#160; You will need the <a href="http://www.microsoft.com/express/phone">development tools</a> in order to open, edit view.&#160; The only disclaimer I make is that the code works.&#160; Not all of it is pretty, and in some places I haven’t gone back to fix things I fixed elsewhere (i.e. walking XML for Bit.ly versus for Twitter).</p>
<p>This specific post is about some of the things that gave me the biggest problems in getting started.&#160; The app that I built is pretty simple.&#160; It’s meant to allow you to connect to Twitter, pull down your friend timeline, and parse the timeline looking for URLs sent by people you follow.&#160; I use Twitter for content discovery, and this is my ultimate time waster app.&#160; When you click on a link the listbox, some additional calls are made via the <a href="http://code.google.com/p/bitly-api/wiki/ApiDocumentation">Bit.ly API</a>, and the <a href="http://help.tweetmeme.com/2009/04/07/api-documentation/">TweetMeme API</a>, to get additional information like the number of retweets that article has, the title of the page referenced and the number of clicks as tracked by Bit.ly.</p>
<p> <span id="more-377"></span>
</p>
<h1>Making Async Calls to Web Services</h1>
<p>Wow, what a huge pain this was <strong>for me</strong> to figure out.&#160; When you do some web searching about how to connect to web services in C#, you will invariably find yourself staring at content about <a href="http://msdn.microsoft.com/en-us/library/system.net.webclient(VS.80).aspx">WebClient class</a>.&#160; I couldn’t make this work for me, and now that I am 3 weeks into it, I can’t remember what the specific issue was.&#160; Something about Twitter not doing Basic Auth correctly, and needing to set the username and password in the header, necessitating the use of <a href="http://msdn.microsoft.com/en-us/library/system.net.networkcredential.aspx">NetwrokCredentials</a>.</p>
<p>In any event, I had to use the HttpWebRequest.&#160; This is where things got challenging for me, since I had never done any async programming in C# or Silverlight.&#160; [Apologies for the wonky formatting in the code samples, but I have a narrow blog and the style isn’t doing auto wrap]</p>
<pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">void</span> GetStatuses()
{
    NetworkCredential nc = <span class="kwrd">new</span> NetworkCredential { UserName =</pre>
<p>
  </p>
<pre class="csharpcode">                          _username, Password = _password };

    <span class="kwrd">string</span> url = <span class="str"><a href="http://twitter.com/statuses/friends_timeline.xml?">http://twitter.com/statuses/friends_timeline.xml?</a></span></pre>
<p>
  </p>
<pre class="csharpcode"><span style="color: #006080">                              </span> + <span class="str">&quot;count=&quot;</span> + _count + (_sinceID &gt; 0 ?</pre>
<p>
  </p>
<pre class="csharpcode">                               <span class="str">&quot;&amp;since_id=&quot;</span> + _sinceID : <span class="str">&quot;&quot;</span>);
    System.Net.HttpWebRequest request =</pre>
<p>
  </p>
<pre class="csharpcode">                              (HttpWebRequest)HttpWebRequest.Create(url);
    request.Method = <span class="str">&quot;GET&quot;</span>;

    <span class="kwrd">if</span> (_username != <span class="kwrd">null</span> &amp;&amp; _password != <span class="kwrd">null</span>)
    {
        request.Credentials = nc;
    }

    IAsyncResult token = request.BeginGetResponse(</pre>
<p>
  </p>
<pre class="csharpcode"><span class="kwrd">                                  new</span> AsyncCallback(GetStatusesCallBack),</pre>
<p>
  </p>
<pre class="csharpcode">                                  request);

}</pre>
<p>Sorting out how to correctly get the async call done, and then set up the callback, was where I completely threw a rod.&#160; Basically, you need to set up a web request to happen on its own thread, and then you need to assign a delegate function to process the response.&#160; Figuring out how to do this took me 2 days, mostly because I didn’t know what questions to ask, or what terms to use when searching online, and in this specific case, only code that I did discover was useless for me because I was trying to learn something new and didn’t understand the samples I found.</p>
<p>Looking at the call, you may notice that I am using the REST API from Twitter, and setting the since_id and count variables to ensure that I am getting the data that I want.&#160; This is so I can reuse this function to make subsequent calls while the app is running and only get the new tweets.&#160; Twitter makes things pretty easy to get the data you want.</p>
<p>Here’s how you handle the async callback function to actually issue the HTTP request and process the data which comes back:</p>
<pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">void</span> GetStatusesCallBack(IAsyncResult result)
{
    <span class="kwrd">bool</span> foundNewSinceID = <span class="kwrd">false</span>;

    <span class="kwrd">try</span>
    {

        WebResponse response = ((HttpWebRequest)result.AsyncState)</pre>
<p>
  </p>
<pre class="csharpcode">                                       .EndGetResponse(result);
        StreamReader reader = <span class="kwrd">new</span> StreamReader(response</pre>
<p>
  </p>
<pre class="csharpcode">                                       .GetResponseStream());
        <span class="kwrd">string</span> responseString = reader.ReadToEnd();</pre>
<p><!--<br />
.csharpcode, .csharpcode pre<br />
{<br />
font-size: small;<br />
color: black;<br />
font-family: consolas, &#8220;Courier New&#8221;, courier, monospace;<br />
background-color: #ffffff;<br />
/*white-space: pre;*/<br />
}<br />
.csharpcode pre { margin: 0em; }<br />
.csharpcode .rem { color: #008000; }<br />
.csharpcode .kwrd { color: #0000ff; }<br />
.csharpcode .str { color: #006080; }<br />
.csharpcode .op { color: #0000c0; }<br />
.csharpcode .preproc { color: #cc6633; }<br />
.csharpcode .asp { background-color: #ffff00; }<br />
.csharpcode .html { color: #800000; }<br />
.csharpcode .attr { color: #ff0000; }<br />
.csharpcode .alt<br />
{<br />
background-color: #f4f4f4;<br />
width: 100%;<br />
margin: 0em;<br />
}<br />
.csharpcode .lnum { color: #606060; } &#8211;></p>
<p>[note – this is a code snippet, and won’t work without closing that try{} and having an associated catch block]&#160; What you end up with in the responseString is well formatted XML returned from Twitter.&#160; Once I understood how to make these async calls, I was able to write any number of functions which handled getting data from other web services.</p>
<h1>XML Processing</h1>
<p>Oh man, what a complete cluster this was for me.&#160; The <a href="http://apiwiki.twitter.com/Twitter-API-Documentation">Twitter API is well documented</a>, and so I figured it would be pretty easy to parse the XML.&#160; Unfortunately, I didn’t know what was available to me in Silverlight on Windows Phone 7 Series, so I started by asking Bing.</p>
<p>First things first, especially for those who are not well versed in Silverlight or Visual Studio.&#160; If you want to parse XML, do yourself a huge favor and add a reference (“Project/Add Reference”) to System.Xml.Linq in your project.&#160; Do that first.&#160; With that, you can use XDocument.&#160; Do it not, and you will have code that looks like this (focus on the while loop at the bottom):</p>
<pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">void</span> GetStatusesCallBack(IAsyncResult result)
{
    <span class="kwrd">string</span> _name = <span class="kwrd">null</span>;
    <span class="kwrd">string</span> _status = <span class="kwrd">null</span>;
    <span class="kwrd">long</span> _tweetID = 0;

    <span class="kwrd">bool</span> foundNewSinceID = <span class="kwrd">false</span>;

    <span class="rem">//need to set header for the sinceid and num replies</span>
    <span class="kwrd">try</span>
    {
        WebResponse response = ((HttpWebRequest)result</pre>
<p>
  </p>
<pre class="csharpcode">                                    .AsyncState).EndGetResponse(result);
        StreamReader reader = <span class="kwrd">new</span> StreamReader(response</pre>
<p>
  </p>
<pre class="csharpcode">                                    .GetResponseStream());
        <span class="kwrd">string</span> responseString = reader.ReadToEnd();

        XmlReader xreader = XmlReader.Create(<span class="kwrd">new</span></pre>
<p>
  </p>
<pre class="csharpcode">                                    StringReader(responseString));

        <span class="kwrd">while</span> (xreader.Read())
        {
            <span class="kwrd">if</span> (xreader.NodeType == XmlNodeType.Element</pre>
<p>
  </p>
<pre class="csharpcode">                           &amp;&amp; xreader.Name == <span class="str">&quot;text&quot;</span>)
            {
                _status = CheckForLinks(xreader.ReadInnerXml());
            }

            <span class="kwrd">if</span> (xreader.NodeType == XmlNodeType.Element</pre>
<p>
  </p>
<pre class="csharpcode">                            &amp;&amp; xreader.Name == <span class="str">&quot;name&quot;</span>)
            {
                _name = xreader.ReadInnerXml();
            }</pre>
<p><!--<br />
.csharpcode, .csharpcode pre<br />
{<br />
font-size: small;<br />
color: black;<br />
font-family: consolas, &#8220;Courier New&#8221;, courier, monospace;<br />
background-color: #ffffff;<br />
/*white-space: pre;*/<br />
}<br />
.csharpcode pre { margin: 0em; }<br />
.csharpcode .rem { color: #008000; }<br />
.csharpcode .kwrd { color: #0000ff; }<br />
.csharpcode .str { color: #006080; }<br />
.csharpcode .op { color: #0000c0; }<br />
.csharpcode .preproc { color: #cc6633; }<br />
.csharpcode .asp { background-color: #ffff00; }<br />
.csharpcode .html { color: #800000; }<br />
.csharpcode .attr { color: #ff0000; }<br />
.csharpcode .alt<br />
{<br />
background-color: #f4f4f4;<br />
width: 100%;<br />
margin: 0em;<br />
}<br />
.csharpcode .lnum { color: #606060; } &#8211;></p>
<p>Let’s talk about what’s going on here.&#160; It turns out that if you <a href="http://www.bing.com/search?q=.net+read+XML&amp;form=QBRE&amp;qs=n">ask Bing “.net read XML,”</a> you will get posts and articles that talk about how to use XmlReader.&#160; The first 10 links that come back all seem to point to this as a pattern for reading XML in .NET.&#160; Not knowing what I was doing, I figured that this was the way to do it.&#160; And so I set about building the code that would read XML and check for certain elements along the way.</p>
<p>This is not the right way to do this.&#160; Absolutely, unequivocally not the right way.&#160; As in, please, please, please don’t put yourself through this.&#160; Never mind that if you get back poorly formed XML you have problems.&#160; Or that sometimes the reader just decides not to work correctly.&#160; Or you get some weird data back, and you throw an exception, which is non-deterministic to find because the bug only surfaced when <a href="http://twitter.com/davemcclure">Dave McClure posted something strange</a> in his stream.&#160; Oh, and the fact that Twitter use an “id” both for users and status, which makes the stream read a bit strange and easy to get the wrong value for statusID or userID.&#160; Or that you end up with an unwieldy set of IF statements to parse your XML.&#160; So to recap, don’t read XML this way.&#160; Bad.&#160; Very bad.</p>
<p>The right way to do things is to put the resposeString into an XDocument, and then perform a LINQ query against it.&#160; You gain access to the XDocument via System.Xml.Linq, which is why I suggested adding that as a reference to your project.</p>
<pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">void</span> GetStatusesCallBack(IAsyncResult result)
{
    <span class="kwrd">bool</span> foundNewSinceID = <span class="kwrd">false</span>;

    <span class="kwrd">try</span>
    {

        WebResponse response = ((HttpWebRequest)result</pre>
<p>
  </p>
<pre class="csharpcode">                                        .AsyncState).EndGetResponse(result);
        StreamReader reader = <span class="kwrd">new</span> StreamReader(response</pre>
<p>
  </p>
<pre class="csharpcode">                                        .GetResponseStream());
        <span class="kwrd">string</span> responseString = reader.ReadToEnd();

        XDocument twitterXML = XDocument.Parse(responseString);

        var twitObjs = from x <span class="kwrd">in</span> twitterXML.Descendants(<span class="str">&quot;status&quot;</span>)
                      select <span class="kwrd">new</span>
        {
            tweetId = x.Element(<span class="str">&quot;id&quot;</span>).Value,
            text = x.Element(<span class="str">&quot;text&quot;</span>).Value,
            name = x.Element(<span class="str">&quot;user&quot;</span>).Element(<span class="str">&quot;name&quot;</span>).Value,
            profile_image_url = x.Element(<span class="str">&quot;user&quot;</span>)</pre>
<p>
  </p>
<pre class="csharpcode">                                        .Element(<span class="str">&quot;profile_image_url&quot;</span>).Value,
            userId = x.Element(<span class="str">&quot;user&quot;</span>).Element(<span class="str">&quot;id&quot;</span>).Value
        };</pre>
<p><!--<br />
.csharpcode, .csharpcode pre<br />
{<br />
font-size: small;<br />
color: black;<br />
font-family: consolas, &#8220;Courier New&#8221;, courier, monospace;<br />
background-color: #ffffff;<br />
/*white-space: pre;*/<br />
}<br />
.csharpcode pre { margin: 0em; }<br />
.csharpcode .rem { color: #008000; }<br />
.csharpcode .kwrd { color: #0000ff; }<br />
.csharpcode .str { color: #006080; }<br />
.csharpcode .op { color: #0000c0; }<br />
.csharpcode .preproc { color: #cc6633; }<br />
.csharpcode .asp { background-color: #ffff00; }<br />
.csharpcode .html { color: #800000; }<br />
.csharpcode .attr { color: #ff0000; }<br />
.csharpcode .alt<br />
{<br />
background-color: #f4f4f4;<br />
width: 100%;<br />
margin: 0em;<br />
}<br />
.csharpcode .lnum { color: #606060; } &#8211;></p>
<p>Isn’t that just so much prettier?&#160; I had used LINQ before, but it was to access SQL objects, and for whatever reason I didn’t think to use LINQ to XML.&#160; Shame on me.&#160; n00bnotes hall of fame for sure.</p>
<h1>Exceptions on the UI Thread</h1>
<p>This one is very simple to understand and fix once you know what is going on, but a complete pain if you don’t understand why.&#160; The “why” is that there is one UI thread in Silverlight.&#160; If you want to update anything that is UI related, and your code isn’t being executed by the UI (for example, a delegate callback function), then you need to get that code onto the UI thread.&#160; This is very, very simple to do, but I didn’t know how to ask the question to get the answer, and so it took me a little while to find the answer.</p>
<pre class="csharpcode">Dispatcher.BeginInvoke(() =&gt;
{
    <span class="rem">//these are some basic UI changes that you can make once on the UI thread</span>
    grdTweets.Visibility = System.Windows.Visibility.Collapsed;
    grdLogin.Visibility = System.Windows.Visibility.Visible;

    txtPassword.Password = String.Empty;
    twitHelp.SetUserPass(txtUsername.Text, txtPassword.Password);

});</pre>
<p>The lambda function off the Dispatcher is how you get your UI updating code onto the UI thread.&#160; Just put your code in between the {} and you are all good.</p>
<p>My next post will talk about how I built out the listbox, which is the main piece of UI functionality, and the fun and interesting discovery process on how to use data binding.&#160; I now love data binding.&#160; A couple of days ago I hated it with a passion, but mostly because my code was wrong, I didn’t understand exactly what I was doing – more like just enough to sort of make things work, but not quite right enough that I noticed, and didn’t know how to debug.&#160; So much fun. <img src='http://www.manyniches.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.manyniches.com/n00b-notes/windows-phone-7-series-developer-experience/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>Did Google Just Release Task Queues?</title>
		<link>http://www.manyniches.com/n00b-notes/did-google-just-release-task-queues/</link>
		<comments>http://www.manyniches.com/n00b-notes/did-google-just-release-task-queues/#comments</comments>
		<pubDate>Thu, 18 Jun 2009 22:21:11 +0000</pubDate>
		<dc:creator>Brandon Watson</dc:creator>
				<category><![CDATA[N00b Notes]]></category>
		<category><![CDATA[App Engine]]></category>
		<category><![CDATA[GOOG]]></category>
		<category><![CDATA[queues]]></category>
		<category><![CDATA[tasks]]></category>

		<guid isPermaLink="false">http://www.manyniches.com/n00b-notes/did-google-just-release-task-queues/</guid>
		<description><![CDATA[I just logged into my App Engine dashboard to check out some things, and look what popped up on the left hand side nav bar.&#160; Intrigued, I clicked on the link to reveal a page with the below text.&#160; That link to task queues goes nowhere of note at this time. Truth be told, I [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 5px; margin-right: 5px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.manyniches.com%2Fn00b-notes%2Fdid-google-just-release-task-queues%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.manyniches.com%2Fn00b-notes%2Fdid-google-just-release-task-queues%2F&amp;source=BrandonWatson&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p><a href="http://www.manyniches.com/wp-content/uploads/2009/06/image.png"><img style="border-right-width: 0px; margin: 5px 10px 0px 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" align="left" src="http://www.manyniches.com/wp-content/uploads/2009/06/image-thumb.png" width="244" height="219" /></a> </p>
<p>I just logged into my App Engine dashboard to check out some things, and look what popped up on the left hand side nav bar.&#160; Intrigued, I clicked on the link to reveal a page with the below text.&#160; That <a href="http://code.google.com/appengine/kb/general.html#taskqueue">link to task queues</a> goes nowhere of note at this time.</p>
<p>Truth be told, I have been doing some really nasty stuff on App Engine using cron jobs, so getting access to the tasks stuff would make me really happy.</p>
<p>I went and <a href="http://dl.google.com/io/2009/pres/Th_1045_Offline_Processing_On_App_Engine_A_Look_Ahead.pdf">pulled the presentation</a> from <a href="http://code.google.com/events/io/">Google IO</a> about offline processing to see if I could figure out how to use them in the absence of any <a href="http://code.google.com/appengine/docs/">sanctioned content on their dev portal</a>.</p>
<p><a href="http://www.manyniches.com/wp-content/uploads/2009/06/image5.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.manyniches.com/wp-content/uploads/2009/06/image-thumb5.png" width="500" height="60" /></a></p>
<p>UPDATE: Looks like was ahead of the gun by mere minutes, and the links now go places that have info on task queues.&#160; Good for GOOG, though I haven’t wrapped my mind around this new feature yet.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.manyniches.com/n00b-notes/did-google-just-release-task-queues/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>ASP.NET MVC Book Sample Chapter</title>
		<link>http://www.manyniches.com/n00b-notes/aspnet-mvc-book-sample-chapter/</link>
		<comments>http://www.manyniches.com/n00b-notes/aspnet-mvc-book-sample-chapter/#comments</comments>
		<pubDate>Thu, 19 Mar 2009 21:41:00 +0000</pubDate>
		<dc:creator>Brandon Watson</dc:creator>
				<category><![CDATA[N00b Notes]]></category>
		<category><![CDATA[ASP.net]]></category>
		<category><![CDATA[aweseome]]></category>
		<category><![CDATA[conrey]]></category>
		<category><![CDATA[haack]]></category>
		<category><![CDATA[hanselman]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Mix09]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[scottgu]]></category>

		<guid isPermaLink="false">http://www.manyniches.com/n00b-notes/aspnet-mvc-book-sample-chapter/</guid>
		<description><![CDATA[I have professed my love for ASP.NET MVC, but have come to hate the documentation by blog.  I have been checking Amazon and the local book stores for a book that would help spell out many of the topics not covered in Scottgu’s blog posts. Here at Mix09, Scott Hanselman is giving out links to [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 5px; margin-right: 5px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.manyniches.com%2Fn00b-notes%2Faspnet-mvc-book-sample-chapter%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.manyniches.com%2Fn00b-notes%2Faspnet-mvc-book-sample-chapter%2F&amp;source=BrandonWatson&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>I have professed my love for <a href="http://www.asp.net/mvc">ASP.NET MVC</a>, but have come to hate the documentation by blog.  I have been checking <a href="http://www.amazon.com">Amazon</a> and the local book stores for a book that would help spell out many of the topics not covered in <a href="http://weblogs.asp.net/scottgu/">Scottgu’s blog posts</a>.</p>
<p>Here at <a href="http://live.visitmix.com/Default.aspx">Mix09</a>, Scott Hanselman is giving out links to the first chapter of his forthcoming book, coauthored with ScottGu, <a href="http://www.haacked.com/">Phil Haack</a>, and <a href="http://blog.wekeroad.com/">Rob Conrey</a>.  Apparently they are doing this under creative commons, and want you to have it.  “First chapter?,” you ask.  What’s the big deal?  Well…it’s <strong>185 pages</strong>, and is a start to finish app creation.  That is how I want to learn this stuff, and was psyched to see it.  I am working through the content myself, but wanted to share the link.</p>
<p>The book title is “<a href="http://www.tinyurl.com/aspnetmvc">Professional ASP.NET MVC 1.0</a>” and they have a link to the <a href="http://aspnetmvcbook.s3.amazonaws.com/aspnetmvc-nerdinner_v1.pdf">free chapter</a>.  Enjoy.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.manyniches.com/n00b-notes/aspnet-mvc-book-sample-chapter/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>ASP.NET MVC &#8211; Passing Data Around</title>
		<link>http://www.manyniches.com/n00b-notes/aspnet-mvc-passing-data-around/</link>
		<comments>http://www.manyniches.com/n00b-notes/aspnet-mvc-passing-data-around/#comments</comments>
		<pubDate>Wed, 04 Feb 2009 19:49:27 +0000</pubDate>
		<dc:creator>Brandon Watson</dc:creator>
				<category><![CDATA[N00b Notes]]></category>
		<category><![CDATA[ASP.net]]></category>
		<category><![CDATA[data structures]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[Scott Guthrie]]></category>
		<category><![CDATA[scottgu]]></category>

		<guid isPermaLink="false">http://www.manyniches.com/uncategorized/aspnet-mvc-passing-data-around/</guid>
		<description><![CDATA[I’ve made no secrets of the fact that I am n00btaculous with regard to ASP.NET.&#160; The first week or so with the MVC was pretty painful for the simple fact that the available information online is somewhat dated.&#160; That sounds weird when talking about something that hasn’t even shipped yet, but here’s what I mean.&#160; [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 5px; margin-right: 5px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.manyniches.com%2Fn00b-notes%2Faspnet-mvc-passing-data-around%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.manyniches.com%2Fn00b-notes%2Faspnet-mvc-passing-data-around%2F&amp;source=BrandonWatson&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>I’ve made no secrets of the fact that I am n00btaculous with regard to ASP.NET.&#160; The first week or so with the MVC was pretty painful for the simple fact that the available information online is somewhat dated.&#160; That sounds weird when talking about something that hasn’t even shipped yet, but here’s what I mean.&#160; If you do a <a href="http://search.live.com/results.aspx?q=asp.net+mvc&amp;form=QBLH&amp;qs=n">search for “ASP.NET MVC”</a>, you will find that some of the links head off to <a href="http://weblogs.asp.net/scottgu/archive/2007/10/14/asp-net-mvc-framework.aspx">Scott Guthrie’s blog</a>.&#160; This is a good thing, since he’s the big cheese here at Microsoft responsible for a great many things, including MVC.&#160; Here’s the problem: that link is from a blog post in late 2007.&#160; As a n00b, I’m wasn’t sure whether or not anything has changed, especially since we are now at a release candidate for ASP.NET MVC, rendering the code samples useless in my mind.</p>
<p>With that in mind, I have been scrabbling around looking for information.&#160; To <a href="http://www.imdb.com/title/tt0094027/">quote Jaime Escalante</a>, I was “like a blind man, in a dark room, looking for a black cat that’s not even there.”</p>
<p>It turns out that the <a href="http://www.asp.net">ASP.NET site</a> completely redid the samples that they had for MVC, which is pretty awesome when you think about it.&#160; Head’s up, it’s easy to get lost in the site and not find the “new hotness.”&#160; You want this <a href="http://www.asp.net/mvc/">link to their MVC content</a>, and not this <a href="http://www.asp.net/learn/mvc-videos/">link off their “Learn” tab</a>.</p>
<p>Now, to the task at hand.&#160; With the Controllers and Views, you can separate your data from the presentation.&#160; Awesome.&#160; How do I get the data from Controller to View?&#160; When I first started learning, it wasn’t clear that I could pass more than one piece of data, because most of the samples I saw had something along the lines of:</p>
<div class="code_snippet">return View(data);</div>
<p>where “data” could be any single object.&#160; As with any function, you wouldn’t expect to be able to return multiple objects.&#160; So, n00b that I am, I was trying to create all kinds of complicated structures to pass different data back.&#160; For example, I did something like:</p>
<div class="code_snippet">List&lt;Dictionary&lt;string, int&gt;&gt; myData;</div>
<p>and proceeded to dump data into this complicated structure.&#160; Don’t do this.&#160; I then tried to create custom classes for returning different sets data as one repository.&#160; Please don’t do that.&#160; There is a much, much simpler solution, which I missed in the tutorial sets, because it’s not clearly called out as to what they are doing.&#160; You can pass whatever data you want back to your view, and label it.&#160; I took advantage of this as follows:</p>
<div class="code_snippet">ViewData[&quot;myDict1&quot;] = myDict1;    <br />ViewData[&quot;myDict2&quot;] = myDict2;     <br />return View();     </div>
<p>Once you do that, your View can access the data as follows:</p>
<div class="code_snippet">&lt;% foreach (KeyValuePair&lt;string,int&gt;kvp in (Dictionary&lt;string,int&gt;)ViewData[&quot;MyDict1&quot;]) %&gt;    <br />&lt;% { %&gt;     <br />&lt;%= String.Format(&quot;Key: {0}, Value: {1}&quot;,kvp.Key, kvp.Value) %&gt;     <br />&lt;% } %&gt;     </div>
<p>You can replace the “myDict1” with “myDict2” if you want to access that data set.&#160; The data structures can be whatever you want – I just used two dictionaries for illustrative purposes.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.manyniches.com/n00b-notes/aspnet-mvc-passing-data-around/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>ASP.NET &#8211; Membership Hides Its Privileges</title>
		<link>http://www.manyniches.com/n00b-notes/aspnet-membership-hides-its-privileges/</link>
		<comments>http://www.manyniches.com/n00b-notes/aspnet-membership-hides-its-privileges/#comments</comments>
		<pubDate>Tue, 03 Feb 2009 23:54:00 +0000</pubDate>
		<dc:creator>Brandon Watson</dc:creator>
				<category><![CDATA[N00b Notes]]></category>
		<category><![CDATA[ASP.net]]></category>
		<category><![CDATA[membership]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[SQL Express]]></category>

		<guid isPermaLink="false">http://www.manyniches.com/n00b-notes/aspnet-membership-hides-its-privileges/</guid>
		<description><![CDATA[One of the problems I have had thus far with my foray into ASP.NET has been a simple concept.&#160; How do you deal with users logging in.&#160; Not so much the actual mechanics of it, but where is the data, and how can I get to it?&#160; By default, when you are using forms based [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 5px; margin-right: 5px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.manyniches.com%2Fn00b-notes%2Faspnet-membership-hides-its-privileges%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.manyniches.com%2Fn00b-notes%2Faspnet-membership-hides-its-privileges%2F&amp;source=BrandonWatson&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>One of the problems I have had thus far with my foray into ASP.NET has been a simple concept.&#160; How do you deal with users logging in.&#160; Not so much the actual mechanics of it, but where is the data, and how can I get to it?&#160; By default, when you are using forms based authentication, that data is stored in tables that you cannot easily get to, and certainly not in the Solutions Explorer.&#160; Essentially, nothing is showing up in your “App_Data” node, and there is no .MDF file to add from your project directory.</p>
<p>What then are you to do when you want to have direct access to your membership tables from within Visual Studio?&#160; Well, let me walk you through the steps, as I did them, to achieve this.&#160; I won’t say that this is the official way, but it’s what worked for me.&#160; I hope to save you some of the pain and suffering associated with my searching on the web to find these answers.</p>
<h5><font face="Lucida Sans Unicode">Create your new project</font></h5>
<p>This is self-explanatory.</p>
<h5>Turn on forms based authentication</h5>
<p>This is accomplished by editing your web.config file.&#160; Look for the following:</p>
<div class="code_snippet">&lt;authentication mode=&quot;Forms&quot;&gt;    <br />&#160; &lt;forms loginUrl=&quot;~/Account/Login&quot; /&gt;     <br />&lt;/authentication&gt;</div>
<h5><font face="Lucida Sans Unicode">Run the ASP.NET Configuration</font></h5>
<p>It’s important that you don’t look for this option (under the “Project” menu) when you have the web.config file as your open window.&#160; It won’t be there.</p>
<h5>Add A User</h5>
<p>Click on the security tab, and from there you can manage your users.&#160; Add one.&#160; One time when I did this, I saw the following error:</p>
<div class="code_snippet">The following message may help in diagnosing the problem: <b>Could not find stored procedure &#8216;dbo.aspnet_CheckSchemaVersion&#8217;.</b></div>
<p>The annoying bit was that when I tested the connection, through the tool, it was able to successfully establish a connection.&#160; Wonderful.&#160; I am not sure how I fixed this the one time I hit it, but I wanted to throw it out there as a potential issue.</p>
<h5>The Unfun Complicated Bit</h5>
<p>So, this is where having a friend on the dev team is important.&#160; I had read one of the <a href="http://www.asp.net/learn/mvc/tutorial-17-cs.aspx">tutorials over at asp.net</a> which had content on this topic. They tell you to run “aspnet_regsql” from a Visual Studio command prompt.&#160; If you do nothing else, know this: if you are using SQL Express, your server that you want to connect to is in the form of &lt;machine name&gt;\sqlexpress.&#160; If you get that wrong, this tool will fail.&#160; Always.&#160; That’s roughly two hours I just saved you.</p>
<p>I am not sure what this tool did that this command line bit didn’t do for me (courtesy developer friend).</p>
<p><strong>NAVIGATE TO</strong>:</p>
<div class="code_snippet">C:\Windows\Microsoft.NET\Framework\v2.0.50727&gt;</div>
<p><strong>RUN</strong>: </p>
<div class="code_snippet">aspnet_regsql.exe -d &quot;&lt;path to project dir&gt;\&lt;projectname&gt;\App_Data\ASPNETDB.MDF&quot; </div>
<p> With the following options:
<div class="code_snippet">-A all -C &quot;Data Source=.\SQLEXPRESS;Integrated Security=True;User Instance=True&quot;</div>
<p>If everything goes according to plan, you will see:</p>
<div class="code_snippet">Start adding the following features:    <br />Membership     <br />Profile     <br />RoleManager     <br />Personalization     <br />SqlWebEventProvider     <br />&#8230;..     <br />Finished.</div>
<p>If not, you will see many errors. This broke for me when the ASPNETDB.MBF file was not already there.&#160; It showed up for me only after I had successfully built and run the project and added a user.&#160; The <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=F4E4EE26-4BC5-41ED-80C9-261336B2A5B6&amp;displaylang=en">asp.net mvc</a> default app has a new user wizard, which I could also use (which I did when I hit that stored proc error above in “Add a User.”&#160; Of course it worked, and I don’t know why.</p>
<h5>Add the Database File</h5>
<p>In the Solutions Explorer Window, right mouse click, and select “Add/Existing Item.”&#160; Select ASPNETDB.MDF.&#160; Careful that you don’t select the _log file.&#160; I did that.&#160; Don’t do what I did.&#160; Fail.</p>
<p>There you go.&#160; A step by step, “how the hell do I get my user tables into my project so that I can edit them” tutorial.&#160; Hopefully this saves some poor unsuspecting n00b some time.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.manyniches.com/n00b-notes/aspnet-membership-hides-its-privileges/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>FriendFeed Helping Twitter?</title>
		<link>http://www.manyniches.com/n00b-notes/friendfeed-helping-twitter/</link>
		<comments>http://www.manyniches.com/n00b-notes/friendfeed-helping-twitter/#comments</comments>
		<pubDate>Fri, 23 Jan 2009 05:18:04 +0000</pubDate>
		<dc:creator>Brandon Watson</dc:creator>
				<category><![CDATA[N00b Notes]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[FriendFeed]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[n00b]]></category>
		<category><![CDATA[Scoble]]></category>
		<category><![CDATA[Twitter]]></category>

		<guid isPermaLink="false">http://www.manyniches.com/n00b-notes/friendfeed-helping-twitter/</guid>
		<description><![CDATA[A few weeks back, I wanted to pick up C#.  I have been hacking away in Python for a couple years, but now that I am in the Developer Platform Marketing division at Microsoft, I really felt it was my obligation to pick up some C# skillz. The first thing I went and wrote was [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 5px; margin-right: 5px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.manyniches.com%2Fn00b-notes%2Ffriendfeed-helping-twitter%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.manyniches.com%2Fn00b-notes%2Ffriendfeed-helping-twitter%2F&amp;source=BrandonWatson&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>A few weeks back, I wanted to pick up C#.  I have been hacking away in Python for a couple years, but now that I am in the Developer Platform Marketing division at <a href="http://www.microsoft.com">Microsoft</a>, I really felt it was my obligation to pick up some C# skillz.</p>
<p>The first thing I went and wrote was a small app that utilizes the <a href="http://friendfeed.com/api/">FriendFeed API</a>.  It polls the service for their public timeline.  It then iterates through each entry in that list and gets the last 20 posts (I think) for each user for the entries in the public timeline.  Within the code, I added the following:</p>
<div class="code_snippet">dictRegExStrings.Add(&#8220;Twitter&#8221;, &#8220;.com/(.+)&#8221;);<br />
dictRegExStrings.Add(&#8220;Digg&#8221;, &#8220;.com/users/(.+)&#8221;);<br />
dictRegExStrings.Add(&#8220;delicious&#8221;, &#8220;.com/(.+)&#8221;);<br />
dictRegExStrings.Add(&#8220;Last.fm&#8221;, &#8220;.fm/user/(.+)/&#8221;);<br />
dictRegExStrings.Add(&#8220;FriendFeed&#8221;, &#8220;.com/(.+)&#8221;);</div>
<p>What that allowed me to do was to take the service name and then use my list of RegExes to pull the user name for those services (in case I wanted to go ping their APIs or do other such things, like recreate a social graph&#8230;).  I have about 10 of them that I wanted to track specifcally, and I list the ones above to show how I was going about doing my matches against the FriendFeed object.  I iterate through the public feed fetches, as seen in this code snippet:</p>
<div class="code_snippet">FriendFeedClient ffClient = new FriendFeedClient();</p>
<p>ServiceNames = new List&lt;string&gt;();<br />
for (int i = 0; i &lt; length; i++)<br />
{<br />
    pubFeed = ffClient.FetchPublicFeed();</p></div>
<p>I do my tabulating, and move on to the next public feed fetch.  I was happy that I got the code running, and how easy the FriendFeed guys have made it to use their service in this way.  In order to be a nice net citizen, I put a sleep in my for loop.  In any event, here’s the interesting bit: when I first wrote the code I started dumping data to a text file.  The last one I dumped before today was:</p>
<blockquote><p><span style="font-family: Courier; font-size: x-small;">11/27/08 1:00AM</span><br />
<span style="font-family: Courier; font-size: x-small;">Twitter:        10433   23.84 %<br />
Delicious:      681     1.56 %<br />
Last.FM:        465     1.06 %<br />
Digg:           3933    8.99 %<br />
FriendFeed:     3157    7.21 %<br />
Facebook:       703     1.61 %<br />
YouTube:        580     1.33 %<br />
Disqus:         33      0.08 %<br />
Tumblr:         1599    3.65 %<br />
StumbleUpon:    433     0.99 %<br />
Flickr:         762     1.74 %<br />
Blogs:          13273   30.32 %<br />
Other:          7718    17.63 %</span></p></blockquote>
<p>Before today, it was merely a novelty for me.  I actually ran the code again on Monday, and had seen that the Twitter traffic had trended up to 40%.  However, this week, it was announced that FriedFeed had implemented a feature allowing their users to import their Twitter friends.  It was postulated by some that this would <a href="http://friendfeed.com/e/c301c7ac-91a4-4c54-b7f1-28d513f2e074/Whoa-I-am-now-following-a-TON-more-people-on/">have the impact of an increase in traffic/usage for FriendFeed</a>.  Others went so far to <a href="http://twitter.com/Scobleizer/status/1137727185">say that the announcement by Twitter to up their rate limits on APIs was a shot at FriendFeed</a>.</p>
<p>Since I had the data just sitting there on my computer, I decided to do another run just to see what was going on.  I ran it a couple of times.  Once with five iterations, once with 10, and something like 300 iterations.  Here are those results:</p>
<blockquote><p><span style="font-family: Courier; font-size: x-small;">01/22/09 12:00PM</span><br />
<span style="font-family: Courier; font-size: x-small;">Twitter:        93121   52.45 %<br />
Delicious:      9431    5.31 %<br />
Last.FM:        1302    0.73 %<br />
Digg:           9200    5.18 %<br />
FriendFeed:     13743   7.74 %<br />
Facebook:       4165    2.35 %<br />
YouTube:        1337    0.75 %<br />
Disqus:         335     0.19 %<br />
Tumblr:         2645    1.49 %<br />
StumbleUpon:    1827    1.03 %<br />
Flickr:         1858    1.05 %<br />
Blogs:          19425   10.94 %<br />
Other:          19169   10.80 %</span></p></blockquote>
<p>Look at the percentages for FriendFeed and Twitter.  Quite a dramatic difference.  More importantly is that the posts identified as FriendFeed have stayed flat, but Twitter is zooming.  Whether this translates out to people viewing Twitter through FriendFeed has yet to be seen, but the Twitter usage is way up.</p>
<p>Since I’ve got the code, I will continue to track this for a while.  In fact, I think I am going to create and <a href="http://www.azure.com">Azure app</a> that has a worker role that just pings FriendFeed from time to time and track this data over time, and publish the date for everyone to see.  That’ll be my next code project.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.manyniches.com/n00b-notes/friendfeed-helping-twitter/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>ASP.NET MVC How I Love Thee</title>
		<link>http://www.manyniches.com/n00b-notes/aspnet-mvc-how-i-love-thee/</link>
		<comments>http://www.manyniches.com/n00b-notes/aspnet-mvc-how-i-love-thee/#comments</comments>
		<pubDate>Thu, 22 Jan 2009 22:52:49 +0000</pubDate>
		<dc:creator>Brandon Watson</dc:creator>
				<category><![CDATA[N00b Notes]]></category>
		<category><![CDATA[ASP.net]]></category>
		<category><![CDATA[Django]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[RoR]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.manyniches.com/uncategorized/aspnet-mvc-how-i-love-thee/</guid>
		<description><![CDATA[So far, I am in love with ASP.NET MVC.  Let’s just hope this doesn’t turn out like my love affair with other potentially fleeting items, like the great Seattle snow storm of December 2008.  I think my Facebook update on that one was: After throwing my hands up in disgust yesterday, while trying to do [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 5px; margin-right: 5px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.manyniches.com%2Fn00b-notes%2Faspnet-mvc-how-i-love-thee%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.manyniches.com%2Fn00b-notes%2Faspnet-mvc-how-i-love-thee%2F&amp;source=BrandonWatson&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>So far, I am in love with ASP.NET MVC.  Let’s just hope this doesn’t turn out like my love affair with other potentially fleeting items, like the great Seattle snow storm of December 2008.  I think <a href="http://www.facebook.com/profile.php?id=623225&amp;ref=profile">my Facebook update</a> on that one was:</p>
<p><img style="border-right: 0px; border-top: 0px; display: block; float: none; margin: 0px auto 5px; border-left: 0px; border-bottom: 0px" title="FacebookStatus1" src="http://www.manyniches.com/wp-content/uploads/2009/01/facebookstatus1.png" border="0" alt="FacebookStatus1" width="456" height="75" />After throwing my hands up in disgust yesterday, while trying to do a simple thing like put some data in a database, get it out, and display it arbitrarily on a page, I got a note from a friend who really urged me to check out the <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=A24D1E00-CD35-4F66-BAA0-2362BDDE0766&amp;displaylang=en">MVC beta that Microsoft</a> had put out.  The download was easy enough, and once I had that done, I wandered over to <a href="http://www.asp.net/learn/mvc-videos/video-395.aspx">tutorials on ASP.net</a> to see what all the fuss was about.  Remember, MVC is how my mind thinks about building web apps, so this was a welcome starting point.</p>
<p><a href="http://www.manyniches.com/wp-content/uploads/2009/01/samplemvc.png"><img style="border-right: 0px; border-top: 0px; display: inline; margin: 0px 5px 0px 0px; border-left: 0px; border-bottom: 0px" title="SampleMVC" src="http://www.manyniches.com/wp-content/uploads/2009/01/samplemvc-thumb.png" border="0" alt="SampleMVC" width="326" height="735" align="left" /></a> First off, the default project code is quite cumbersome.  There’s a ton of files that get created, which I am sure are great to get started, but without context, they are a bit overwhelming.  Remember, I am approaching this as someone who quite literally has no idea what is going on.</p>
<p>However, if you take a closer look at what they have included, you will see that there was some care given to the functionality that comes to your right out of the box.</p>
<p>The application itself doesn’t do much, but it does have user account functionality built in for you.  For most people building applications, they are going to want to have the ability to create user accounts.  More importantly, if you did into the code, what you see is that the user accounts was implemented without using the asp:login controls.  Trust me, you are very happy about this.  The login page uses tables, instead of CSS (<a href="http://www.stirman.net">my good friend, the UI Guru</a>, always makes such a <strong>big deal</strong> of table-less UI), so no points for style.  You get it…style…style sheets?  Anyone?</p>
<p>Another bonus was that they had the good sense to throw in the JQuery JavaScript files.  I don’t know JS, but from reading enough headlines at <a href="http://news.ycombinator.com/">Hacker News</a>, I know JQuery is what you want.  Eventually I will get around to learning some JS goodness, but I suspect that will come after a very turbulent affair with CSS.</p>
<p>After watching that short video on how to build a task list, I felt like I had all the information I needed to get started building the My3Words app.  Sure enough, within a much shorter period of time, I had a working prototype which allowed me to input usernames, and words, and that data routed into the database, and was able to display that data on an arbitrary page.  I cannot tell you how happy that made me.</p>
<p>So there you have it.  If you, like me, have done some MVC development (even a teeny tiny bit), I am pretty confident you are going to find this set of Microsoft technologies much easier around which to wrap your brain.  The next post will have the walk through of my building some base functionality of the My3Words app.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.manyniches.com/n00b-notes/aspnet-mvc-how-i-love-thee/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Fun Times With ASP.NET</title>
		<link>http://www.manyniches.com/n00b-notes/fun-times-with-aspnet/</link>
		<comments>http://www.manyniches.com/n00b-notes/fun-times-with-aspnet/#comments</comments>
		<pubDate>Thu, 22 Jan 2009 06:22:16 +0000</pubDate>
		<dc:creator>Brandon Watson</dc:creator>
				<category><![CDATA[N00b Notes]]></category>
		<category><![CDATA[Add new tag]]></category>
		<category><![CDATA[ASP.net]]></category>
		<category><![CDATA[Django]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[RoR]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.manyniches.com/n00b-notes/aspnet-issues/</guid>
		<description><![CDATA[First off, there’s the two worlds of doing things with ASP.NET.  Actually, there’s three if you count classic ASP, but who’s looking at that?  The first path that I went down in trying to wrap my head around ASP.NET was the web forms method of development.  The bulk of the content online is targeted at [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 5px; margin-right: 5px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.manyniches.com%2Fn00b-notes%2Ffun-times-with-aspnet%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.manyniches.com%2Fn00b-notes%2Ffun-times-with-aspnet%2F&amp;source=BrandonWatson&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>First off, there’s the two worlds of doing things with ASP.NET.  Actually, there’s three if you count classic ASP, but who’s looking at that?  The first path that I went down in trying to wrap my head around ASP.NET was the web forms method of development.  The bulk of the content online is targeted at this way of building apps, and it was the methodology switched to around the time ASP became ASP.NET.  The second path is the MVC path, and we will get to that in a bit.</p>
<p>At first, I was happy with the materials that I had come upon for learning ASP.NET.  There appeared to be no shortage of books available, and plenty of results turned up in the <a href="http://search.live.com/results.aspx?q=learning+asp.net&amp;form=QBLH&amp;qs=n">live.com search</a> (37.1 million to be exact).  The first book that I got from our library (yes, <a href="http://www.microsoft.com">Microsoft</a> has it’s own library, and it’s awesome) was <a href="http://www.amazon.com/Microsoft-ASP-NET-3-5-Step/dp/0735624267/ref=pd_bbs_sr_1?ie=UTF8&amp;s=books&amp;qid=1232584793&amp;sr=8-1">ASP.NET 3.5 Step By Step</a>.  The ratings on Amazon were good, so it seemed like a reasonable starting point.  For kicks, I also grabbed a couple of others.</p>
<p>Here’s my first problem with the ASP.NET literature that I have seen thus far.  For the most part, they really, really want you to understand how ASP.NET works, internally, before you can do anything.  Unfortunately for the <a href="http://en.wikipedia.org/wiki/ADHD">ADHD</a> generation, we want to build things, and we can’t be bothered with details.  Page upon page upon page of HTTP pipelines and other minutia.</p>
<p>I myself learn from examples; preferably code tied to a real application.  Too often in books, when there is sample code, the author provides a dump of the code, as if they are trying to say “look how much code I can write,” when all that does is make me want to close the book.  Reading source code is hard, and certainly reading someone else’s is even harder.  Truth be told, that’s why I embarked on this endeavor…to put out postings which were step by step about how I built something in the hope that some other novice would appreciate that I am going through exactly what they are going through.  I know I am not the best developer out there, and I am going to make a ton of stupid mistakes, but no one wants to feel stupid when they are trying to learn something new, and stupid is all I felt trying to learn the forms method of development for ASP.NET.</p>
<p>ASP.NET has a very cool feature called “code behind” which basically separates the code from the HTML for your pages.  I thought this was cleaner than trying to interleave the C# code into the HTML.  That is until I tried to access code that wasn’t part of the code behind source.  I am sure that if I had kept at it long enough I would have sorted through my issues, but for whatever reason, I could not make it work where I had a function in one .CS file and call it form a code behind file.  If you are trying to do this, things to look out for are the differences between “&lt;%=” and “&lt;%”.  That “=” matters quite a bit.  Another thing to be on the look out for, which they seemingly never cover in the code samples and books, is how and when to use includes and the “using” directives.  Remembering that one thing, more than anything, has caused me pain and suffering that I don’t want to recount.  Again, I know I am not the ace developer, but imagine if you have read this far, you aren’t either.</p>
<p>Further annoyances around getting started were things like trying to find useful tutorials online.  Here’s a great exercise.  Perform the following searches:</p>
<ul>
<li><span style="font-family: Lucida Sans Unicode;">Ruby on Rails tutorial (<a href="http://www.google.com/search?hl=en&amp;q=ruby+on+rails+tutorial&amp;aq=0&amp;oq=ruby+on+rails">google</a>, <a href="http://search.live.com/results.aspx?q=ruby+on+rails+tutorial&amp;form=QBLH&amp;qs=AS">live</a>)</span></li>
<li><span style="font-family: Lucida Sans Unicode;">Python tutorials (<a href="http://www.google.com/search?hl=en&amp;q=python+tutorial">google</a>, <a href="http://search.live.com/results.aspx?q=python+tutorial&amp;form=QBRE&amp;qs=n">live</a>)</span></li>
<li><span style="font-family: Lucida Sans Unicode;">ASP.net tutorials (<a href="http://www.google.com/search?hl=en&amp;q=asp.net+tutorial">google</a>, <a href="http://search.live.com/results.aspx?q=asp.net+tutorial&amp;form=QBRE&amp;qs=n">live</a>)</span></li>
</ul>
<p>Did you do it?  How many clicks did it take you to get to useful information for ASP.net?  You would think that first link to the <a href="http://www.w3schools.com/aspnet/default.asp">W3Schools Tutorial</a> would be a good one.  It took me 5 clicks to get to the first bit of writing code.  Four pages of really superfluous stuff.  It actually felt like the whole site was set up for SEO and ads.  Not that there’s anything wrong with that, but contrast that experience with the Ruby on Rails example.  <a href="http://wiki.rubyonrails.org/rails/pages/Tutorial">One click</a> from the first returned link, and you are writing code.  Still a doubter?  Python was <a href="http://docs.python.org/tutorial/">two clicks</a> from the first returned link.  My point in all of this is it simply shouldn’t be hard to get started with a web app platform.</p>
<p>In all fairness, I eventually removed the word “tutorial” from my search term and landed at the <a href="http://www.asp.net">asp.net site</a>.  They have many informative articles, videos, etc, upon which to feast, but it took me a while to reduce my search terms.  Unfortunately, the video content at ASP.net suffers from three issues, in my humble opinion.  First, it’s dated – many of the <a href="http://www.asp.net/learn/videos/">video lessons for ASP.NET</a> are several years old, and are specific to ASP.NET 2.0, not 3.5.  The <a href="http://www.asp.net/learn/3.5-videos/">ASP.NET 3.5 videos</a> all assume you know what the heck you are doing.  Second, the bulk of the intro lesson videos that you can view display visual basic code.  I was a VB6 nerd, so I can appreciate that, but it bothered me that some of the videos didn’t have C# tutorials with C# on screen.  I get wanting to be language independent, but all of the tutorials should be in the two major Microsoft languages.  I know that sounds like a nit, but it’s important for people trying to get up to speed on your platform.  Don’t alienate them, and don’t make it hard.  Third, and last, is the same fatal flaw as the books; the heavy reliance on the forms and server controls for the programming model.  I get it.  People want to see immediate results, and “yeah” I made a grid of data from a database, but when you have specific ideas about things you want to do, and they don’t fit into this notion of using server side controls, it gets difficult to digest the information.  It simply doesn’t line up with the type of apps that breadth developers are building; it feels more geared toward enterprise developers building quick apps for intranets.</p>
<p>Here’s a great example of my difficulties: I wanted to connect to a database.  I created a simple table in SQL Express (that alone was a fun exercise to discuss another time).  I plowed through a bunch of content, all of it showing how “easy” it was to data bind controls.  All well and good, but what I wanted to do was execute a query and put text on the screen.  Eventually I figured out how to create a Data Set.  Have a gander at this first search result which shows up when searching for “<a href="http://www.beansoftware.com/ASP.NET-Tutorials/DataSet-DataAdapter.aspx">asp.net data set</a>.”  Make heads or tails of that.  Oh, and don’t make the mistake of not knowing the name of the data set as defined in the properties window of Visual Studio.  you kind of need to know that.  I didn’t of course.  Further, I took quite a bit of head banging trying to understand why I needed to declare adapter as follows:</p>
<p>UserWordsDSTableAdapters.UserWordsTableAdapter myAdapter = new UserWordsDSTableAdapters.UserWordsTableAdapter();</p>
<p>YIKES!  Thank goodness for auto-complete and intellisense.  Unfortunately, because C# is strongly typed, and because I couldn’t remember that the Data Set was called UserWordsDS, which then gives me the UserWordsDSTableAdapters, I had a hell of a time getting the adapter object created.  Nothing about using the Data Set was easy to just wrap my brain around.  Perhaps one day I will appreciate that there are Get functions that I have created which have the SQL queries in them, and in order to get the data, I have to create a UserWordsDS.UserWordsDataTable object, and then set that equal to the return value of the myAdapter.GetData() function, but I doubt it.  It just feels like obfuscation for the sake of obfuscation.</p>
<p>Finally having the ability to get data from the database had me hopeful, but this is where I ran into the problem of not understanding why I couldn’t create a new .CS file in the project, and use the very same code that I had used in a code behind file to access data and either return a string or write the Response object.  It was at this point that I threw my hands up.  I actually had three different books on my desk, all in a desperate attempt to figure out how to call C# from the aspx file.  I gave up.  And then I discovered ASP.NET MVC.  We’ll leave that post for tomorrow, but let’s just say I got more done in two hours then I did in a couple of days of “learning” traditional ASP.NET.  Must be my Django and Rails tendencies coming through.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.manyniches.com/n00b-notes/fun-times-with-aspnet/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>My3Words</title>
		<link>http://www.manyniches.com/n00b-notes/my3words/</link>
		<comments>http://www.manyniches.com/n00b-notes/my3words/#comments</comments>
		<pubDate>Thu, 22 Jan 2009 01:05:21 +0000</pubDate>
		<dc:creator>Brandon Watson</dc:creator>
				<category><![CDATA[N00b Notes]]></category>
		<category><![CDATA[ASP.net]]></category>
		<category><![CDATA[Django]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[RoR]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.manyniches.com/n00b-notes/my3words/</guid>
		<description><![CDATA[Description: I want to build an app that has value for self development within organizations.  The app will have user accounts, which you will need in order to leave feedback and view your own feedback.  People can enter 3 words about another person, for whom they must have their email.  I may restrict feedback to [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 5px; margin-right: 5px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.manyniches.com%2Fn00b-notes%2Fmy3words%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.manyniches.com%2Fn00b-notes%2Fmy3words%2F&amp;source=BrandonWatson&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p><strong>Description</strong>: I want to build an app that has value for self development within organizations.  The app will have user accounts, which you will need in order to leave feedback and view your own feedback.  People can enter 3 words about another person, for whom they must have their email.  I may restrict feedback to people of the same top level domain, but I haven’t decided.  All feedback will be anonymous.  The 3 words are meant to be the two that you like and the one that people say about you when you leave the room.  I want to be able to display a tag cloud of all the words in the system on the default page, with the positive words in green and the negative words in red.  Further, once someone logs in, I want to have multiple clouds representing:</p>
<ul>
<li>words about you</li>
<li>words you have written about others</li>
<li>words written by others about people you have written about</li>
<li>words written by others about who have written about you</li>
</ul>
<p>So there it is in a nutshell.  I am going to start the N00b Notes with my quest to get this done.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.manyniches.com/n00b-notes/my3words/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

