<?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>Sean Lynch</title>
	<atom:link href="http://sean-lynch.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://sean-lynch.net</link>
	<description>.Net and HTML5 developer</description>
	<lastBuildDate>Thu, 02 Jan 2014 15:15:32 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.3.25</generator>
	<item>
		<title>Generics Primer &#8211; Part 1</title>
		<link>http://sean-lynch.net/generics-primer-part-1/</link>
		<comments>http://sean-lynch.net/generics-primer-part-1/#comments</comments>
		<pubDate>Thu, 02 Jan 2014 15:15:32 +0000</pubDate>
		<dc:creator><![CDATA[Sean Lynch]]></dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[featured]]></category>
		<category><![CDATA[generics]]></category>

		<guid isPermaLink="false">http://sean-lynch.net/?p=232</guid>
		<description><![CDATA[When generics were first released, the generic collections where the first place that I used them. They removed a lot of the boilerplate code when it came to creating strongly typed collections. In 1.x you would inherit from the base class of the type of collection you wanted, and then implement strongly typed versions of&#8230;]]></description>
				<content:encoded><![CDATA[<p><span style="font-size: 13px;">When generics were first released, the generic collections where the first place that I used them. They removed a lot of the boilerplate code when it came to creating strongly typed collections. In 1.x you would inherit from the base class of the type of collection you wanted, and then implement strongly typed versions of methods such as Add, Remove, Contains.</span><a style="font-size: 13px;" title="An example of that can be found here." href="http://msdn.microsoft.com/en-US/library/system.collections.dictionarybase(v=vs.80).aspx" target="_blank"> An example of this can be found here.</a><span style="font-size: 13px;"> Thanks to generics you don&#8217;t need to create a MyClass1List and a MyClass2List you can simply instantiate a new List&lt;MyClass1&gt;() and new List&lt;MyClass2&gt; without needing to write the plumbing code to have this work.</span></p>
<p>[gist id=8192633]</p>
<p>When .Net 3.5 was released it included one of my favorite features in .Net, LINQ which is a set of extension methods that make extensive use of generics, allowing for removal of much of the boilerplate involved with searching collections.</p>
<p>[gist id=8192749]</p>
<p>In my next post I will talk about creating some simple generic classes and methods.</p>
]]></content:encoded>
			<wfw:commentRss>http://sean-lynch.net/generics-primer-part-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting imports working with dotless and CssBundles</title>
		<link>http://sean-lynch.net/getting-imports-working-with-dotless-and-cssbundles/</link>
		<comments>http://sean-lynch.net/getting-imports-working-with-dotless-and-cssbundles/#comments</comments>
		<pubDate>Wed, 12 Sep 2012 02:27:22 +0000</pubDate>
		<dc:creator><![CDATA[Sean Lynch]]></dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[MS Mvc]]></category>

		<guid isPermaLink="false">http://sean-lynch.net/?p=155</guid>
		<description><![CDATA[I was watching Single Page Apps with HTML5, Web API, Knockout and jQuery by John Papa on pluralsight and one of the pieces was sending compiled less files down using the bundling. [gist id=3703799] Unfortunately this did not work while using @import because the current directory was set to my IIS Express directory. After searching most suggestions&#8230;]]></description>
				<content:encoded><![CDATA[<p>I was watching <a href="http://pluralsight.com/training/Courses/TableOfContents/spa">Single Page Apps with HTML5, Web API, Knockout and jQuery</a> by John Papa on pluralsight and one of the pieces was sending compiled less files down using the bundling.</p>
<p>[gist id=3703799]</p>
<p>Unfortunately this did not work while using @import because the current directory was set to my IIS Express directory. After searching most suggestions were to use Directory.SetCurrentDirectory but didn&#8217;t really like that solution so this is what I decided on:</p>
<p>[gist id=3689144 ]</p>
]]></content:encoded>
			<wfw:commentRss>http://sean-lynch.net/getting-imports-working-with-dotless-and-cssbundles/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Migrating to WordPress with URL Rewriting</title>
		<link>http://sean-lynch.net/migrating-to-wordpress-with-url-rewriting/</link>
		<comments>http://sean-lynch.net/migrating-to-wordpress-with-url-rewriting/#comments</comments>
		<pubDate>Sun, 14 Mar 2010 04:38:29 +0000</pubDate>
		<dc:creator><![CDATA[Sean Lynch]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://sean-lynch.net/?p=78</guid>
		<description><![CDATA[Recently I switched from using SubText to WordPress as my blog engine. The reason for the switch was to get access to all of the plug ins available, I could have added the functionality, but unfortunately I find myself a bit time starved as of late. In order to prevent all of my old permalinks&#8230;]]></description>
				<content:encoded><![CDATA[<p>Recently I switched from using <a title="SubText" href="http://subtextproject.com" target="_blank">SubText</a> to <a class="zem_slink" title="WordPress" rel="homepage" href="http://wordpress.org">WordPress</a> as my blog engine. The reason for the switch was to get access to all of the plug ins available, I could have added the functionality, but unfortunately I find myself a bit time starved as of late.</p>
<p>In order to prevent all of my old permalinks links from breaking, while moving from a /year/month/day/postname format to simply having postname as the url, I am using IIS7&#8217;s URL Rewriting Module. It turned out to be quite simple to do this, and here are the entries that change the requests to the new Url Scheme:</p>
<p><code>&lt;rule name="Aspx" enabled="false" stopProcessing="true"&gt;<br />
&lt;match url="archive/[0-9][0-9][0-9][0-9]/[0-9][0-9]/[0-9][0-9]/([A-Za-z0-9-_.]+).aspx" /&gt;<br />
&lt;conditions logicalGrouping="MatchAny" /&gt;<br />
&lt;action type="Redirect" url="http://sean-lynch.net/{R:1}" /&gt;<br />
&lt;/rule&gt;<br />
&lt;rule name="Rss" enabled="false" stopProcessing="true"&gt;<br />
&lt;match url="rss.aspx" /&gt;<br />
&lt;conditions logicalGrouping="MatchAny" /&gt;<br />
&lt;action type="Redirect" url="/feed" redirectType="Permanent" /&gt;<br />
&lt;/rule&gt;<br />
</code></p>
<p>This has been working well, the only issue that I have run into so far is that categories in subtext were marked with numbers by default, and google&#8217;s crawler is finding them as broken links. I haven&#8217;t decided how to handle these links yet.</p>
<div class="zemanta-pixie" style="margin-top: 10px; height: 15px;"><a class="zemanta-pixie-a" title="Reblog this post [with Zemanta]" href="http://reblog.zemanta.com/zemified/6735b628-629b-4b94-808f-f240acefa1bf/"><img class="zemanta-pixie-img" style="border: medium none; float: right;" src="http://img.zemanta.com/reblog_e.png?x-id=6735b628-629b-4b94-808f-f240acefa1bf" alt="Reblog this post [with Zemanta]" /></a><span class="zem-script more-related pretty-attribution"><script src="http://static.zemanta.com/readside/loader.js" type="text/javascript"></script></span></div>
<div id="_mcePaste" style="overflow: hidden; position: absolute; left: -10000px; top: 73px; width: 1px; height: 1px;">&lt;rule name=&#8221;RemovedDefault&#8221; enabled=&#8221;false&#8221; stopProcessing=&#8221;true&#8221;&gt;<br />
&lt;match url=&#8221;(.+)default.aspx&#8221; /&gt;<br />
&lt;conditions logicalGrouping=&#8221;MatchAny&#8221;&gt;<br />
&lt;add input=&#8221;{URL}&#8221; pattern=&#8221;default.aspx&#8221; /&gt;<br />
&lt;/conditions&gt;<br />
&lt;action type=&#8221;Redirect&#8221; url=&#8221;http://sean-lynch.net/{R:1}&#8221; /&gt;<br />
&lt;/rule&gt;</div>
]]></content:encoded>
			<wfw:commentRss>http://sean-lynch.net/migrating-to-wordpress-with-url-rewriting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DotNetOpenAuth with AppDirectory removed</title>
		<link>http://sean-lynch.net/dotnetopenauth-with-appdirectory-removed/</link>
		<comments>http://sean-lynch.net/dotnetopenauth-with-appdirectory-removed/#comments</comments>
		<pubDate>Wed, 03 Mar 2010 05:11:54 +0000</pubDate>
		<dc:creator><![CDATA[Sean Lynch]]></dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[OpenId]]></category>
		<category><![CDATA[WebQuestBuilder]]></category>
		<category><![CDATA[featured]]></category>

		<guid isPermaLink="false">http://sean-lynch.net/?p=51</guid>
		<description><![CDATA[In my previous post I had talked about my decision to implement OpenId, and how DotNetOpenAuth worked well for this. In this post I will talk a little about the only issue that I ran into while doing this. The root of this issue had to do with how my hosting is setup for sites&#8230;]]></description>
				<content:encoded><![CDATA[<p>In my <a href="http://sean-lynch.net/open-id-with-dotnetopenid/">previous post</a> I had talked about my decision to implement OpenId, and how DotNetOpenAuth worked well for this. In this post I will talk a little about the only issue that I ran into while doing this.</p>
<p>The root of this issue had to do with how my hosting is setup for sites that have low traffic. I host these sites on winhost which allows for an unlimited number of domain pointers. They also have the URL Rewrite module, so I can rewrite <a href="http://webquestbuilder.com/">http://webquestbuilder.com/</a> to http://webquestbuilder.com/sitedir enabling the site to be moved later when demand requires more horsepower without having to deal with the removal of the sub directory.</p>
<p>The problem that came from this setup was that DotNetOpenAuth determined that the releam was webquestbuilder.com/sitedir instead of webquestbuilder.com, and returned from openid with to the sitedir/authenticate.  <a href="http://blog.nerdbank.net/" target="_blank">Andrew Arnott</a> pointed me in the right direction pretty quick after my tweet. Here is what I ended up with to fix this, it is in 2 parts.</p>
<p>The first is making the request:<br />
<code><br />
if (isInSubDir)<br />
{<br />
request = openid.CreateRequest(Request.Form["openid_identifier"], new Realm("http://webquestbuilder.com/"),<br />
new Uri("http://webquestbuilder.com/User/Authenticate/"));<br />
}<br />
else<br />
{<br />
request = openid.CreateRequest(Request.Form["openid_identifier"]);<br />
}</code><br />
The second part is dealing with the response:<br />
<code><br />
var isInSubDir = Request.ApplicationPath!="/";<br />
IAuthenticationResponse response;<br />
if (isInSubDir)<br />
{<br />
var absoluteUri = httpRequest.Url.AbsoluteUri;<br />
var rawUrl = httpRequest.RawUrl;<br />
if(isInSubDir)<br />
{<br />
absoluteUri = absoluteUri.Replace(Request.ApplicationPath, "");<br />
rawUrl = rawUrl.Replace(Request.ApplicationPath, "");<br />
}<br />
var httpRequestInfo = new HttpRequestInfo(httpRequest.HttpMethod, new Uri(absoluteUri), rawUrl, headers, httpRequest.InputStream);<br />
response = openid.GetResponse(httpRequestInfo); �<br />
}<br />
else<br />
{<br />
response = openid.GetResponse();<br />
}</code></p>
]]></content:encoded>
			<wfw:commentRss>http://sean-lynch.net/dotnetopenauth-with-appdirectory-removed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Open Id with DotNetOpenId</title>
		<link>http://sean-lynch.net/open-id-with-dotnetopenid/</link>
		<comments>http://sean-lynch.net/open-id-with-dotnetopenid/#comments</comments>
		<pubDate>Wed, 03 Mar 2010 00:28:00 +0000</pubDate>
		<dc:creator><![CDATA[Sean Lynch]]></dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[OpenId]]></category>
		<category><![CDATA[WebQuestBuilder]]></category>

		<guid isPermaLink="false">http://apilibrary.com/slynchblog/2010/03/02/open-id-with-dotnetopenid/</guid>
		<description><![CDATA[I recently integrated OpenId into a project that I am working on with my wife, WebQuest Builder in order to avoid the extra considerations related to storing user password. Originally I had planned on using RPXNow in order to do this. But after reading about how realms worked, specifically that Google gives a different identifier&#8230;]]></description>
				<content:encoded><![CDATA[<p>I recently integrated OpenId into a project that I am working on with my wife, <a href="http://webquestbuilder.com/">WebQuest Builder</a> in order to avoid the extra considerations related to storing user password.</p>
<p>Originally I had planned on using RPXNow in order to do this. But after reading about how realms worked, specifically that Google gives a different identifier for <a href="http://apilibrary.com/sean/wp-content/uploads/2010/03/RPXNowGoogle.jpg"><img style="display: inline; margin-left: 0px; margin-right: 0px; border-width: 0px;" title="RPXNowGoogle" src="http://apilibrary.com/sean/wp-content/uploads/2010/03/RPXNowGoogle_thumb.jpg" border="0" alt="RPXNowGoogle" width="244" height="184" align="right" /></a> each realm, I decided against this option. Because while RPXNow does have support  for custom realms, webquestbuilder.com instead of webquestbuilder.rpxnow.com, it would cost $99/month in order to get this. And after my wife made a comment that it seemed almost like someone phishing for her account do to the webquestbuilder.rxpnow.com in Googles OpenId form.</p>
<p>The other option that I had been considering had been <a href="http://www.dotnetopenauth.net/">DotNetOpenAuth</a> which was very simple to integrate. It took about an hour to get it running in my development environment. I only had one issue when I pushed it live, which I will go into in a <a title="future post" href="http://sean-lynch.net/dotnetopenauth-with-appdirectory-removed/">future post</a>. For the OpenId selector I used <a href="http://jvance.com/pages/JQueryOpenIDPlugin.xhtml">Jarrett Vance’s Id selector</a> for the Sign In.</p>
<p>After showing it to a few people I ended up making a few tweaks to the Id Selector.<a href="http://apilibrary.com/sean/wp-content/uploads/2010/03/IdSelector.jpg"><img style="display: inline; margin-left: 0px; margin-right: 0px; border-width: 0px;" title="IdSelector" src="http://apilibrary.com/sean/wp-content/uploads/2010/03/IdSelector_thumb.jpg" border="0" alt="IdSelector" width="196" height="120" align="right" /></a> The first  chance that I made was to change it so that the OpenId checkbox did not show up, because a couple of the people I showed it to tried entering in their gmail address instead of Google’s OpenId Url. The other change I did was order them by which providers I thought they were most likely to be using, I hope the Microsoft gets their OpenId provider going soon so that I can integrate hotmail/live accounts into this.</p>
]]></content:encoded>
			<wfw:commentRss>http://sean-lynch.net/open-id-with-dotnetopenid/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ScriptControl question</title>
		<link>http://sean-lynch.net/scriptcontrol-question/</link>
		<comments>http://sean-lynch.net/scriptcontrol-question/#comments</comments>
		<pubDate>Tue, 08 Jul 2008 00:09:08 +0000</pubDate>
		<dc:creator><![CDATA[Sean Lynch]]></dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Work]]></category>

		<guid isPermaLink="false">http://sean-lynch.net/archive/2008/07/07/scriptcontrol-question.aspx</guid>
		<description><![CDATA[As of late I have gotten a chance to use the ASP.Net AJAX extenders and script controls, and so far am really liking how they work, though it would be nice if adding the .js was a little cleaner then manually adding them to the assembly wether in the AssemblyInfo.cs or the controls cs file.&#8230;]]></description>
				<content:encoded><![CDATA[<p>As of late I have gotten a chance to use the ASP.Net AJAX extenders and script controls, and so far am really liking how they work, though it would be nice if adding the .js was a little cleaner then manually adding them to the assembly wether in the AssemblyInfo.cs or the controls cs file.</p>
<p>I have to say I really like the extender and script controls that come with the ASP.NET AJAX. They really are so much nicer to work with then building up Javascript strings in the CS file of the server control. </p>
<p>I do have a question about them though. One of the ScriptControls I made uses a webservice to pull data if the service name is set. At the moment I have it dynamically registering an JSON script service based webservice. Unfortunately I have found that this is not an optimal solution since the name of the Javascript object created by the ScriptService changes depending on the namespace and class name of the service. </p>
<p>I am sure that there is a better way to do this, but I am not exactly certain of it. Any suggestions or links would be appreciated.</p>
<p><img src="http://sean-lynch.net/aggbug/58.aspx" width="1" height="1" /></p>
]]></content:encoded>
			<wfw:commentRss>http://sean-lynch.net/scriptcontrol-question/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Lazy list</title>
		<link>http://sean-lynch.net/lazy-list/</link>
		<comments>http://sean-lynch.net/lazy-list/#comments</comments>
		<pubDate>Wed, 21 May 2008 08:34:18 +0000</pubDate>
		<dc:creator><![CDATA[Sean Lynch]]></dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[MS Mvc]]></category>

		<guid isPermaLink="false">http://sean-lynch.net/archive/2008/05/21/lazy-list.aspx</guid>
		<description><![CDATA[I have been following Rob Conery&#8217;s posts on the MVC Storefront, and trying the repository/pipes-filters for data access that he has been using. While trying out the implementation of a LazyList he was using, I had noticed that the example table was being joined onto the category table. At the time however, I really had&#8230;]]></description>
				<content:encoded><![CDATA[<p>I have been following <a href="http://blog.wekeroad.com/" target="_blank">Rob Conery&#8217;s</a> posts on the MVC Storefront, and trying the repository/pipes-filters for data access that he has been using.</p>
<p>While trying out the implementation of a LazyList he was using, I had noticed that the example table was being joined onto the category table. At the time however, I really had not thought much of it, until I read <a href="http://blog.wekeroad.com/mvc-storefront/mvcstore-intermission2/" target="_blank">MVC Storefront: Brainbender Intermission</a> which got me thinking. </p>
<p>Admittedly, I don&#8217;t really have to much of a problem with it loading all of the examples for all the categories at one time at the moment. However, I figured it would be nice to have it work the way intended, and query the database for the examples in a category only when asked for.</p>
<p>I liked the idea of the LazyList, and since I was already using a Service class for all data access, along with setting up the category hierarchy I moved the creation of the LazyList of examples property into the the GetCategories method of the service class.</p>
<p>It seems that as long as the LazyList is created after the categories .ToList() call it properly works. So I ended up with this code:</p>
<pre class="code">            categories.ForEach(category =&gt;
            {
                category.Examples =
                    <span style="color: rgb(0,0,255)">new</span> <span style="color: rgb(43,145,175)">LazyList
</span>                        &lt;DevExamples.Data.<span style="color: rgb(43,145,175)">Example</span>&gt;(
                        <span style="color: rgb(0,0,255)">from</span> e <span style="color: rgb(0,0,255)">in</span> repository.GetExamples()
                        <span style="color: rgb(0,0,255)">where</span> e.CategoryId == category.ID
                        <span style="color: rgb(0,0,255)">select</span> e);

                <span style="color: rgb(0,0,255)">var</span> subCategories = (<span style="color: rgb(0,0,255)">from</span> sub <span style="color: rgb(0,0,255)">in</span> categories
                                     <span style="color: rgb(0,0,255)">where</span> sub.ParentId == category.ID
                                     <span style="color: rgb(0,0,255)">select</span> sub).ToList();
                category.SubCategories = subCategories;

                subCategories.ForEach(c =&gt; c.Parent = category);

            });
</pre>
<p><a href="http://11011.net/software/vspaste"></a> </p>
<div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:b2911609-4a75-4f29-a40f-6f2131b013b6" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">Technorati Tags: <a href="http://technorati.com/tags/aspnetmvc" rel="tag">aspnetmvc</a></div>
<p><img src="http://sean-lynch.net/aggbug/57.aspx" width="1" height="1" /></p>
]]></content:encoded>
			<wfw:commentRss>http://sean-lynch.net/lazy-list/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Custom Rss Admin feeds</title>
		<link>http://sean-lynch.net/custom-rss-admin-feeds/</link>
		<comments>http://sean-lynch.net/custom-rss-admin-feeds/#comments</comments>
		<pubDate>Mon, 21 Apr 2008 02:34:55 +0000</pubDate>
		<dc:creator><![CDATA[Sean Lynch]]></dc:creator>
				<category><![CDATA[Subtext]]></category>

		<guid isPermaLink="false">http://sean-lynch.net/archive/2008/04/20/custom-rss-admin-feeds.aspx</guid>
		<description><![CDATA[I fixed up the Rss Admin feeds so that modifying web.config (along with new handler classes) would not needed to add a new Admin Rss feed. Also added a simple form to allow administrators to created their own. It is a bit limited, but adding additional options should not be to hard. Though those will have&#8230;]]></description>
				<content:encoded><![CDATA[<p>I fixed up the Rss Admin feeds so that modifying web.config (along with new handler classes) would not needed to add a new Admin Rss feed.</p>
<p>Also added a simple form to allow administrators to created their own. It is a bit limited, but adding additional options should not be to hard. Though those will have to wait till a later date.</p>
<p>On a side note, I found that if I had the option of returning the non-generic  base class, or a generic subclass it makes the code a lot more flexible if you return the non-generic base class if you do not have a need to have the generic type.</p>
<p> </p>
<p> </p>
<div class="wlWriterSmartContent" id="0767317B-992E-4b12-91E0-4F059A8CECA8:c06d95d5-7421-4ef4-a901-c66d789e2806" contenteditable="false" style="PADDING-RIGHT: 0px; DISPLAY: inline; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px">Technorati Tags: <a rel="tag" href="http://technorati.com/tags/Subtext">Subtext</a></div>
<p><img src="http://sean-lynch.net/aggbug/36.aspx" width="1" height="1" /></p>
]]></content:encoded>
			<wfw:commentRss>http://sean-lynch.net/custom-rss-admin-feeds/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Login via Usercontrol View + jQuery</title>
		<link>http://sean-lynch.net/login-via-usercontrol-view-jquery/</link>
		<comments>http://sean-lynch.net/login-via-usercontrol-view-jquery/#comments</comments>
		<pubDate>Tue, 18 Mar 2008 07:55:18 +0000</pubDate>
		<dc:creator><![CDATA[Sean Lynch]]></dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Learning]]></category>

		<guid isPermaLink="false">http://sean-lynch.net/archive/2008/03/18/login-via-usercontrol-view-jquery.aspx</guid>
		<description><![CDATA[Since administration was the next part I wanted to work on. I decided that for the moment I just want a little login for in the upper corner I decided to put the login screen view logic into a user control, and added the following user control named Login.ascx and placed it into the Shared&#8230;]]></description>
				<content:encoded><![CDATA[<p>Since administration was the next part I wanted to work on.</p>
<p>I decided that for the moment I just want a little login for in the upper corner</p>
<p>I decided to put the login screen view logic into a user control, and added the following user control named Login.ascx and placed it into the Shared </p>
<pre class="code"><span style="BACKGROUND: rgb(255,238,98)">&lt;%<span style="COLOR: rgb(0,0,255)" />@</span> <span style="COLOR: rgb(163,21,21)">Control</span> <span style="COLOR: rgb(255,0,0)">Language</span><span style="COLOR: rgb(0,0,255)">="C#"</span> <span style="COLOR: rgb(255,0,0)">Inherits</span><span style="COLOR: rgb(0,0,255)">="System.Web.Mvc.ViewUserControl"</span> <span style="BACKGROUND: rgb(255,238,98)">%&gt;

&lt;%<span style="COLOR: rgb(0,0,255)" />if</span>(!Page.User.Identity.IsAuthenticated) {<span style="BACKGROUND: rgb(255,238,98)">%&gt;
</span>    <span style="COLOR: rgb(0,0,255)">&lt;</span><span style="COLOR: rgb(163,21,21)">form</span> <span style="COLOR: rgb(255,0,0)">action</span><span style="COLOR: rgb(0,0,255)">="/Home/Login"</span> <span style="COLOR: rgb(255,0,0)">method</span><span style="COLOR: rgb(0,0,255)">="post"</span> <span style="COLOR: rgb(255,0,0)">id</span><span style="COLOR: rgb(0,0,255)">="LoginForm"&gt;
</span>        <span style="COLOR: rgb(0,0,255)">&lt;</span><span style="COLOR: rgb(163,21,21)">span</span> <span style="COLOR: rgb(255,0,0)">id</span><span style="COLOR: rgb(0,0,255)">="EmailLabel"&gt;</span>Username:<span style="COLOR: rgb(0,0,255)">&lt;/</span><span style="COLOR: rgb(163,21,21)">span</span><span style="COLOR: rgb(0,0,255)">&gt;&lt;</span><span style="COLOR: rgb(163,21,21)">br</span> <span style="COLOR: rgb(0,0,255)">/&gt;
</span>        <span style="BACKGROUND: rgb(255,238,98)">&lt;%<span style="COLOR: rgb(0,0,255)" />=</span>Html.TextBox(<span style="COLOR: rgb(163,21,21)">"Username"</span>)<span style="BACKGROUND: rgb(255,238,98)">%&gt;<span style="COLOR: rgb(0,0,255)" />&lt;</span><span style="COLOR: rgb(163,21,21)">br</span> <span style="COLOR: rgb(0,0,255)">/&gt;
</span>        <span style="COLOR: rgb(0,0,255)">&lt;</span><span style="COLOR: rgb(163,21,21)">span</span> <span style="COLOR: rgb(255,0,0)">id</span><span style="COLOR: rgb(0,0,255)">="PasswordLabel"&gt;</span>Password:<span style="COLOR: rgb(0,0,255)">&lt;/</span><span style="COLOR: rgb(163,21,21)">span</span><span style="COLOR: rgb(0,0,255)">&gt;&lt;</span><span style="COLOR: rgb(163,21,21)">br</span> <span style="COLOR: rgb(0,0,255)">/&gt;
</span>        <span style="BACKGROUND: rgb(255,238,98)">&lt;%<span style="COLOR: rgb(0,0,255)" />=</span>Html.Password(<span style="COLOR: rgb(163,21,21)">"Password"</span>)<span style="BACKGROUND: rgb(255,238,98)">%&gt;<span style="COLOR: rgb(0,0,255)" />&lt;</span><span style="COLOR: rgb(163,21,21)">br</span> <span style="COLOR: rgb(0,0,255)">/&gt;
</span>         <span style="COLOR: rgb(0,0,255)">&lt;</span><span style="COLOR: rgb(163,21,21)">span</span> <span style="COLOR: rgb(255,0,0)">id</span><span style="COLOR: rgb(0,0,255)">="Error"&gt;
</span>            <span style="BACKGROUND: rgb(255,238,98)">&lt;%<span style="COLOR: rgb(0,0,255)" />=</span>ViewData.ContainsDataItem(<span style="COLOR: rgb(163,21,21)">"Message"</span>) ? ViewData[<span style="COLOR: rgb(163,21,21)">"Message"</span>] + <br />               <span style="COLOR: rgb(163,21,21)">"&lt;BR /&gt;"</span> : <span style="COLOR: rgb(163,21,21)">""</span><span style="BACKGROUND: rgb(255,238,98)">%&gt;
</span>        <span style="COLOR: rgb(0,0,255)">&lt;/</span><span style="COLOR: rgb(163,21,21)">span</span><span style="COLOR: rgb(0,0,255)">&gt;
</span>        <span style="BACKGROUND: rgb(255,238,98)">&lt;%<span style="COLOR: rgb(0,0,255)" />=</span>Html.SubmitButton(<span style="COLOR: rgb(163,21,21)">"Submit"</span>, <span style="COLOR: rgb(163,21,21)">"Login"</span>)<span style="BACKGROUND: rgb(255,238,98)">%&gt;
</span>    <span style="COLOR: rgb(0,0,255)">&lt;/</span><span style="COLOR: rgb(163,21,21)">form</span><span style="COLOR: rgb(0,0,255)">&gt;
</span><span style="BACKGROUND: rgb(255,238,98)">&lt;%</span>}<span style="COLOR: rgb(0,0,255)">else</span> {<span style="BACKGROUND: rgb(255,238,98)">%&gt;
</span>        <span style="COLOR: rgb(0,0,255)">&lt;</span><span style="COLOR: rgb(163,21,21)">span</span><span style="COLOR: rgb(0,0,255)">&gt;</span>Not <span style="BACKGROUND: rgb(255,238,98)">&lt;%<span style="COLOR: rgb(0,0,255)" />=</span>Page.User.Identity.Name <span style="BACKGROUND: rgb(255,238,98)">%&gt;<span style="COLOR: rgb(0,0,255)" />&lt;</span><span style="COLOR: rgb(163,21,21)">br</span> <span style="COLOR: rgb(0,0,255)">/&gt;</span>    
        <span style="BACKGROUND: rgb(255,238,98)">&lt;%<span style="COLOR: rgb(0,0,255)" />=</span>Html.ActionLink&lt;DevExamples.Controllers.<span style="COLOR: rgb(43,145,175)">HomeController</span>&gt;(c =&gt; c.Logout()
            , <span style="COLOR: rgb(163,21,21)">"Logout"</span>, <span style="COLOR: rgb(0,0,255)">new</span> { id = <span style="COLOR: rgb(163,21,21)">"LogoutLink"</span> })<span style="BACKGROUND: rgb(255,238,98)">%&gt;<span style="COLOR: rgb(0,0,255)" />&lt;/</span><span style="COLOR: rgb(163,21,21)">span</span><span style="COLOR: rgb(0,0,255)">&gt;

</span><span style="BACKGROUND: rgb(255,238,98)">&lt;%</span>} <span style="BACKGROUND: rgb(255,238,98)">%&gt;
</span></pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>And added the user control to the masterpage using </p>
<pre class="code"><span style="COLOR: rgb(0,0,255)">&lt;</span><span style="COLOR: rgb(163,21,21)">div</span> <span style="COLOR: rgb(255,0,0)">id</span><span style="COLOR: rgb(0,0,255)">="Login"&gt;</span><span style="BACKGROUND: rgb(255,238,98)">&lt;%<span style="COLOR: rgb(0,0,255)" />=</span>Html.RenderUserControl(<span style="COLOR: rgb(163,21,21)">"~/Views/Shared/Login.ascx"</span>) <span style="BACKGROUND: rgb(255,238,98)">%&gt;</span><span style="COLOR: rgb(163,21,21)">&lt;div</span><span style="COLOR: rgb(0,0,255)">&gt;</span></pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>I was going to use</p>
<pre class="code"><span style="COLOR: rgb(0,0,255)">using</span> (Html.Form&lt;DevExamples.Controllers.<span style="COLOR: rgb(43,145,175)">HomeController</span>&gt;(c=&gt;c.Login()<br />   ,System.Web.Mvc.<span style="COLOR: rgb(43,145,175)">FormExtensions</span>.<span style="COLOR: rgb(43,145,175)">FormMethod</span>.post,<span style="COLOR: rgb(0,0,255)">new</span> {id=<span style="COLOR: rgb(163,21,21)">"LoginForm"</span>}))</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>to create the form (because it is a lot cooler), but couldn&#8217;t get the html attributes to work and was more interested in getting the dynamic stuff working then looking at the code for the extension method in the MVCToolKit, in other words being lazy.</p>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>I thought about putting the authentication checking logic into the controller. But handling it this way made it a bit simpler, and more self contained, so until I find a compelling enough reason I will be leaving it this way.</p>
<p>After I had the user control showing up, I decided to hook up the actual authentication. I decided to go with forms authentication, and set it up using the <a href="http://myheadsexploding.com/images/myheadsexploding_com/WindowsLiveWriter/LoginviaUsercontrolViewjQuery_14D0E/image_4.png"><img style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height="19" alt="image" width="20" border="0" src="http://myheadsexploding.com/images/myheadsexploding_com/WindowsLiveWriter/LoginviaUsercontrolViewjQuery_14D0E/image_thumb_1.png" /></a> button in the solution explorer. </p>
<p>Next it was time to create the login and logout controller actions, which I decided would best fit in the HomeController, At first I had thought to create two separate views, one for when logged in and one for logged out, then remembered <a href="http://haacked.com/">Phil Haack</a>, at least I think it was him, something about being able to use user controls in the RenderView method of the controller. </p>
<p>I ended up with the following two controller actions:</p>
<pre class="code">[<span style="COLOR: rgb(43,145,175)">ControllerAction</span>]
<span style="COLOR: rgb(0,0,255)">public</span> <span style="COLOR: rgb(0,0,255)">void</span> Login()
{
    <span style="COLOR: rgb(0,0,255)">if</span> (!ControllerContext.HttpContext.User.Identity.IsAuthenticated)
    {
        <span style="COLOR: rgb(0,0,255)">if</span> (Request.RequestType == <span style="COLOR: rgb(163,21,21)">"POST"</span>)
        {
            <span style="COLOR: rgb(0,0,255)">string</span> userName = Request.Form[<span style="COLOR: rgb(163,21,21)">"Username"</span>];
            <span style="COLOR: rgb(0,0,255)">string</span> password = Request.Form[<span style="COLOR: rgb(163,21,21)">"Password"</span>];

            <span style="COLOR: rgb(0,0,255)">if</span> (<span style="COLOR: rgb(43,145,175)">Membership</span>.ValidateUser(userName, password))
            {
                <span style="COLOR: rgb(43,145,175)">FormsAuthentication</span>.SetAuthCookie(userName, <span style="COLOR: rgb(0,0,255)">true</span>);
                <span style="COLOR: rgb(0,128,0)">//Set cookie and redirect
</span>                RedirectToAction(<span style="COLOR: rgb(163,21,21)">"Login"</span>);
            }
            <span style="COLOR: rgb(0,0,255)">else
</span>            {
                ViewData.Add(<span style="COLOR: rgb(163,21,21)">"Message"</span>, <span style="COLOR: rgb(163,21,21)">"Invalid Username/Password"</span>);
            }
        }
    }
    RenderView(<span style="COLOR: rgb(163,21,21)">"Login"</span>);
}
[<span style="COLOR: rgb(43,145,175)">ControllerAction</span>]
<span style="COLOR: rgb(0,0,255)">public</span> <span style="COLOR: rgb(0,0,255)">void</span> Logout()
{
    <span style="COLOR: rgb(43,145,175)">FormsAuthentication</span>.SignOut();
    RedirectToAction(<span style="COLOR: rgb(163,21,21)">"Login"</span>);
}
</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>Since it was allowing me to just render out the user control, I decided there was no point to refreshing the whole page, so decided to use a AJAXish way of doing it. So I decided it was time to pick a javascript library. And since <a href="http://haacked.com/archive/2007/12/13/thank-you-for-helping-me-with-my-job-with-asp.net.aspx">Phil had provided a link</a> to  <a href="http://www.chadmyers.com/Blog/archive/2007/12/10/using-script.aculo.us-with-asp.net-mvc.aspx">Using script.aculo.us with ASP.NET MVC</a> by Chad Myers,I decided to go with jQuery for this (that and it seemed to fit better). </p>
<p>After a bit of reading through their tutorials I added this to the header section of the master page.</p>
<pre class="code"><span style="COLOR: rgb(0,0,255)">&lt;</span><span style="COLOR: rgb(163,21,21)">script</span> <span style="COLOR: rgb(255,0,0)">src</span><span style="COLOR: rgb(0,0,255)">="../../Content/jquery.js"</span> <span style="COLOR: rgb(255,0,0)">type</span><span style="COLOR: rgb(0,0,255)">="text/javascript"&gt;&lt;/</span><span style="COLOR: rgb(163,21,21)">script</span><span style="COLOR: rgb(0,0,255)">&gt;
&lt;</span><span style="COLOR: rgb(163,21,21)">script</span> <span style="COLOR: rgb(255,0,0)">src</span><span style="COLOR: rgb(0,0,255)">="../../Content/jquery.form.js"</span> <span style="COLOR: rgb(255,0,0)">type</span><span style="COLOR: rgb(0,0,255)">="text/javascript"&gt;&lt;/</span><span style="COLOR: rgb(163,21,21)">script</span><span style="COLOR: rgb(0,0,255)">&gt;
&lt;</span><span style="COLOR: rgb(163,21,21)">script</span> <span style="COLOR: rgb(255,0,0)">type</span><span style="COLOR: rgb(0,0,255)">="text/javascript"&gt;
</span>    <span style="COLOR: rgb(0,0,255)">var</span> readyFuncs = <span style="COLOR: rgb(0,0,255)">function</span>() { 
        $(<span style="COLOR: rgb(163,21,21)">'#LoginForm'</span>).ajaxForm(<span style="COLOR: rgb(0,0,255)">function</span>(result) { 
            $(<span style="COLOR: rgb(163,21,21)">'#Login'</span>).html(result); 
            $(document).ready(readyFuncs); 
        }); 
        $(<span style="COLOR: rgb(163,21,21)">'#LogoutLink'</span>).click(<span style="COLOR: rgb(0,0,255)">function</span>(){
            $.<span style="COLOR: rgb(0,0,255)">get</span>(<span style="COLOR: rgb(163,21,21)">'/Home/Logout'</span>,<span style="COLOR: rgb(0,0,255)">function</span>(result){
                $(<span style="COLOR: rgb(163,21,21)">'#Login'</span>).html(result);
                $(document).ready(readyFuncs); 
            });
            <span style="COLOR: rgb(0,0,255)">return</span> <span style="COLOR: rgb(0,0,255)">false</span>;
        });
    };
    $(document).ready(readyFuncs);
<span style="COLOR: rgb(0,0,255)">&lt;/</span><span style="COLOR: rgb(163,21,21)">script</span><span style="COLOR: rgb(0,0,255)">&gt;</span></pre>
<p>The only real snag I had run into with this was that each time the Login div was refreshed I had to reregister the events.</p>
<div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:4dd497a4-51ee-4f9b-a55b-e2bd0856f320" style="PADDING-RIGHT: 0px; DISPLAY: inline; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px">Technorati Tags: <a rel="tag" href="http://technorati.com/tags/aspnetmvc">aspnetmvc</a>, <a rel="tag" href="http://technorati.com/tags/jQuery">jQuery</a>, <a rel="tag" href="http://technorati.com/tags/FormsAuthentication">FormsAuthentication</a></div>
<p><img src="http://sean-lynch.net/aggbug/42.aspx" width="1" height="1" /></p>
]]></content:encoded>
			<wfw:commentRss>http://sean-lynch.net/login-via-usercontrol-view-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>.Net based SVN client library</title>
		<link>http://sean-lynch.net/net-based-svn-client-library/</link>
		<comments>http://sean-lynch.net/net-based-svn-client-library/#comments</comments>
		<pubDate>Tue, 18 Mar 2008 08:30:38 +0000</pubDate>
		<dc:creator><![CDATA[Sean Lynch]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://sean-lynch.net/archive/2008/03/18/.net-based-svn-client-library.aspx</guid>
		<description><![CDATA[As an exercise to figure out socket programming I have been messing around with creating an SVN client library to use with DevExamples.com, well actually a generic SC client library that would allow me to change what repository site I was working against, SVN just seemed like the simplest of them at the moment. However,&#8230;]]></description>
				<content:encoded><![CDATA[<p>As an exercise to figure out socket programming I have been messing around with creating an SVN client library to use with DevExamples.com, well actually a generic SC client library that would allow me to change what repository site I was working against, SVN just seemed like the simplest of them at the moment.</p>
<p>However, after thinking about it, I think it would be better to use one that is already built if possible. I just have not been able to find a pure .Net client library. It is also seems rare for a source control library to work without a working folder, which is somewhat limiting when I want to check the propagation of examples using this method on the same machine.</p>
<p>Though I think it would be interesting to write a LINQ to Source provider, as a way to learn expression trees better. Plus it would be nice to be able to not only easily switch hosting providers (the reason I am looking for a pure .Net library) but also to have a standard syntax to allow me to easily switch from SVN to <a href="http://sourcegear.com/vault/index.html">SourceGear&#8217;s Vault</a> (which I use for my personal development projects) to TFS (which we use at work) as the storage system for the examples.</p>
<p>Though <a href="http://www.codeplex.com/SvnBridge">SvnBridge</a> could possibly help with that too.</p>
<div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:b1c1d208-8688-4361-be36-f0dbfa4721fb" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">Technorati Tags: <a href="http://technorati.com/tags/SVN" rel="tag">SVN</a>,<a href="http://technorati.com/tags/Vault" rel="tag">Vault</a>,<a href="http://technorati.com/tags/.Net" rel="tag">.Net</a>,<a href="http://technorati.com/tags/LINQ" rel="tag">LINQ</a></div>
<p><img src="http://sean-lynch.net/aggbug/55.aspx" width="1" height="1" /></p>
]]></content:encoded>
			<wfw:commentRss>http://sean-lynch.net/net-based-svn-client-library/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
