<?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>Ryan's Tech Blog &#187; ASP.NET</title>
	<atom:link href="http://ryepup.unwashedmeme.com/blog/category/aspnet/feed/" rel="self" type="application/rss+xml" />
	<link>http://ryepup.unwashedmeme.com/blog</link>
	<description>mostly tech, mostly rants</description>
	<lastBuildDate>Wed, 04 Jan 2012 03:42:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>brief list of things that make working in C# frustrating</title>
		<link>http://ryepup.unwashedmeme.com/blog/2008/02/13/brief-list-of-things-that-make-working-in-c-frustrating/</link>
		<comments>http://ryepup.unwashedmeme.com/blog/2008/02/13/brief-list-of-things-that-make-working-in-c-frustrating/#comments</comments>
		<pubDate>Wed, 13 Feb 2008 22:58:17 +0000</pubDate>
		<dc:creator>ryan</dc:creator>
				<category><![CDATA[annoying]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://ryepup.unwashedmeme.com/blog/2008/02/13/brief-list-of-things-that-make-working-in-c-frustrating/</guid>
		<description><![CDATA[Problem: .NET framework classes don&#8217;t use interfaces enough Specific example: DataSource / DataBind()are separately defined on Repeater and GridView, (and Control, and many, many others), and my abstract base class doesn&#8217;t care which option an implementor chooses, it just wants to bind the data however the base control wants it. Possible Solutions: Define interface IDataBinding, [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Problem: </strong> .NET framework classes don&#8217;t use interfaces enough</p>
<p><strong>Specific example:</strong> <code>DataSource </code>/ <code>DataBind()</code>are separately defined on <code>Repeater </code> and <code>GridView</code>, (and <code>Control</code>, and many, many others), and my abstract base class doesn&#8217;t care which option an implementor chooses, it just wants to bind the data however the base control wants it.</p>
<p><strong>Possible Solutions:</strong></p>
<ul>
<li>Define interface <code>IDataBinding</code>, class <code>MyRepeater : Repeater, IDataBinding</code>, class <code>MyGridView : GridView, IDataBinding</code>, etc.</li>
<li><strike>Define interface <code>IDataBinding</code>, upgrade to C# 3, use extension methods to add <code>IDataBinding</code></strike> nope, extension methods can&#8217;t do this</li>
<li>Copy/paste identical code from my base class into concrete classes</li>
<li>Use reflection to set <code>DataSource </code>and call <code>DataBind()</code>, completely sidestepping the C# type system</li>
</ul>
<hr />
<strong>Problem: </strong>.NET framework classes not designed for extension: &#8220;<code>cannot override inherited member  'System.Collections.Generic.Dictionary&lt;X, Y&gt;.Add(X, Y)' because it is not marked virtual, abstract, or override</code>&#8220;</p>
<p><strong>Specific Example:</strong> Extending <code>System.Collections.Generic.Dictionary</code> to do some permit a list of values for one key, so adding the first item is stored as a single value, but adding a second value to the same key stores both values in a list.  Error message is: &#8220;<code>cannot override inherited member  'System.Collections.Generic.Dictionary&lt;X, Y&gt;.Add(X, Y)' because it is not marked virtual, abstract, or override</code>&#8220;</p>
<p><strong>Possible Solutions:</strong></p>
<ul>
<li>Define wrapper classes that encapsulates the framework class and implements all the base interfaces, with the vast majority of the code being straight delegation to the framework class:
<pre>
class MyDict : IDictionary, [other interfaces...] {
private Dictionary&lt;X,Y&gt; dict = new Dictionary&lt;X,Y&gt;;
public bool Contains(X key){ return dict.Contains(key);}
[... other simple wrappers...]
}</pre>
</li>
<li>Find a less appropriate framework class that is designed for extension, duplicate behavior of the proper framework class manually, eg: add run-time type checks for <code>Hashtable.Add(object, object) </code>in place of the letting the compiler handle the types as in <code>Dictionary&lt;X,Y&gt;.Add(X, Y)</code></li>
<li>Extend Dictionary&lt;X,Y&gt;, define a method <code>AddList(X,Y)</code>, and avoid using <code>IDictionary</code> in the rest of my code</li>
<li>Upgrade the C# 3, use extension to add function <code>AddList </code>to <code>IDictionary</code>, be sure to include those extensions on every consumer of <code>IDictionary</code></li>
</ul>
<hr />
<strong>Problem:</strong> .NET framwork classes not designed for extension: members declared private/ internal / protected internal</p>
<p><strong>Specific Example:</strong> Storing additional data in <code>ViewState </code>on 2 different controls that have different base classes.   One is a user control, another extends <code>RadioButtonList </code>to provide different UI for the same data</p>
<p><strong>Possible solutions:</strong></p>
<ul>
<li><strike>Upgrade to C# 3, use extension methods to add functions</strike> nope, extension methods can only see public members, <code>ViewState </code>is protected</li>
<li>Use reflection to set <code>ViewState</code></li>
<li>Copy/paste code into each control</li>
<li>Define  interface <code>IPublicViewstate</code>,  class <code>MyRadioButtonList : RadioButtonList, IPublicViewState</code>,  class<code> MyUserControl : UserControl, IPublicViewState</code>,  etc</li>
</ul>
<hr /> As Nathan said, I&#8217;m stuck between a rock and <code>IHardPlace</code>.</p>
]]></content:encoded>
			<wfw:commentRss>http://ryepup.unwashedmeme.com/blog/2008/02/13/brief-list-of-things-that-make-working-in-c-frustrating/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>CAS Authentication in C#</title>
		<link>http://ryepup.unwashedmeme.com/blog/2007/06/19/cas-authentication-in-c/</link>
		<comments>http://ryepup.unwashedmeme.com/blog/2007/06/19/cas-authentication-in-c/#comments</comments>
		<pubDate>Tue, 19 Jun 2007 19:22:42 +0000</pubDate>
		<dc:creator>ryan</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[CAS]]></category>
		<category><![CDATA[open source]]></category>

		<guid isPermaLink="false">http://ryepup.unwashedmeme.com/blog/2007/06/19/cas-authentication-in-c/</guid>
		<description><![CDATA[For a recent project I wanted to authenticate using Central Authentication Service (CAS), a single-sign on server deployed world-wide. My project is in ASP.NET, so I hunted down CASP, a C# class produced by John Tantalo at Case Western Reserve University. Coincidentally, John was also responsible for Planarity, a flash game which has only stolen [...]]]></description>
			<content:encoded><![CDATA[<p>
For a recent project I wanted to authenticate using <a href="http://www.ja-sig.org/products/cas/index.html">Central Authentication Service</a> (CAS), a single-sign on server deployed <a href="http://www.frappr.com/jasigcasdeployers">world-wide</a>.  My project is in ASP.NET, so I hunted down <a href="http://opensource.case.edu/trac_projects/CAS/wiki/CASP">CASP</a>, a C# class produced by <a href="http://wiki.case.edu/User:John.Tantalo">John Tantalo</a> at <a href="http://www.case.edu">Case Western Reserve University</a>.  Coincidentally, John was also responsible for <a href="http://www.planarity.net/">Planarity</a>, a flash game which has only stolen mere days of my life.
</p>
<p>I had a few nits to pick with it, so at the risk of calling his baby ugly:</p>
<ol>
<li>Doesn't handle the latest CAS protocol, <a href="http://www.ja-sig.org/products/cas/overview/cas2_architecture/index.html">CAS2</a></li>
<li>Dumps the authenticated username into Session, which isn't what I wanted</li>
<li>Doesn't use "using" statements when dealing with <a href="http://msdn2.microsoft.com/en-us/library/system.idisposable.aspx">IDisposable</a> objects</li>
<li>Doesn't use XML comments, which .NET tools prefer</li>
<li>Some minor duplication in specifying the login URL and the validation URL.</li>
</ol>
<p>
So, all in all nothing really big.  I ended up going a little nuts with it resolving all my complaints.  It can now speak CAS1 or CAS2, and has a bunch of options that I added in to solve my specific needs.  It seems a little overcomplicated now, but I always get that feeling when I'm thinking in C#.
</p>
<h2>Installation</h2>
<p>Pretty simple:</p>
<ol>
<li>Download the source: <a href="/files/CASP.cs">CASP.cs</a> (BSD license)</li>
<li>Add it to your project</li>
</ol>
<h2>Example usage</h2>
<p>Like Tantalo's CASP, mine is designed to be used from a System.Web.UI.Page, and will redirect the browser about as needed.<br/></p>
<p>Simplest example, uses CAS2 by default</p>
<div class="igBar"><span id="lcsharp-4"><a href="#" onclick="javascript:showPlainTxt('csharp-4'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">C#:</span>
<div id="csharp-4">
<div class="csharp" style="font-family: monospace;">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0600FF;">protected</span> <span style="color: #0600FF;">void</span> Page_Load<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">object</span> sender, EventArgs e<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #FF0000;">string</span> username = CASP.<span style="color: #0000FF;">Authenticate</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;https://login.case.edu/cas/&quot;</span>, <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">Page</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #008080; font-style: italic;">//do whatever with username</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#125;</span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Slightly more complex, using CAS1 and always renewing the authentication ticket</p>
<div class="igBar"><span id="lcsharp-5"><a href="#" onclick="javascript:showPlainTxt('csharp-5'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">C#:</span>
<div id="csharp-5">
<div class="csharp" style="font-family: monospace;">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0600FF;">protected</span> <span style="color: #0600FF;">void</span> Page_Load<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">object</span> sender, EventArgs e<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #FF0000;">string</span> username = CASP.<span style="color: #0000FF;">Authenticate</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;https://login.case.edu/cas/&quot;</span>, <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">Page</span>, <span style="color: #0600FF;">true</span>, <span style="color: #0600FF;">false</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #008080; font-style: italic;">//do whatever with username</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#125;</span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Most complex example, giving you flexibility to decide what to do about errors, etc</p>
<div class="igBar"><span id="lcsharp-6"><a href="#" onclick="javascript:showPlainTxt('csharp-6'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">C#:</span>
<div id="csharp-6">
<div class="csharp" style="font-family: monospace;">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0600FF;">protected</span> <span style="color: #0600FF;">void</span> Page_Load<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">object</span> sender, EventArgs e<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; CASP casp = <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> CASP<span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;https://login.case.edu/cas/&quot;</span>, <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">Page</span>, <span style="color: #0600FF;">true</span><span style="color: #000000;">&#41;</span>; <span style="color: #008080; font-style: italic;">//re-login every time</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>casp.<span style="color: #0000FF;">Login</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0600FF;">try</span> <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color: #FF0000;">string</span> username = casp.<span style="color: #0000FF;">ServerValidate</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>; <span style="color: #008080; font-style: italic;">//or casp.Validate() for CAS1</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">//do whatever with username</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><span style="color: #0600FF;">catch</span> <span style="color: #000000;">&#40;</span>CASP.<span style="color: #0000FF;">ValidateException</span> ex<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">//try again, something was messed up</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; casp.<span style="color: #0000FF;">Login</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">true</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#125;</span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>This code is <a href="http://jcooney.net/archive/2007/02/01/42999.aspx">certified</a>:<br />
<img src='http://ryepup.unwashedmeme.com/blog/wp-content/uploads/2007/06/worksonmymachine_logo_small.png' alt='works on my machine' /></p>
]]></content:encoded>
			<wfw:commentRss>http://ryepup.unwashedmeme.com/blog/2007/06/19/cas-authentication-in-c/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Server Application Unavailable, no event log, .NET 2</title>
		<link>http://ryepup.unwashedmeme.com/blog/2007/02/14/server-application-unavailable-no-event-log-net-2/</link>
		<comments>http://ryepup.unwashedmeme.com/blog/2007/02/14/server-application-unavailable-no-event-log-net-2/#comments</comments>
		<pubDate>Wed, 14 Feb 2007 23:38:12 +0000</pubDate>
		<dc:creator>ryan</dc:creator>
				<category><![CDATA[annoying]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://ryepup.unwashedmeme.com/blog/2007/02/14/server-application-unavailable-no-event-log-net-2/</guid>
		<description><![CDATA[A perplexing error while setting up my new system: Server Application Unavailable The web application you are attempting to access on this web server is currently unavailable. Please hit the "Refresh" button in your web browser to retry your request. Administrator Note: An error message detailing the cause of this specific request failure can be [...]]]></description>
			<content:encoded><![CDATA[<p>A perplexing error while setting up my new system:</p>
<blockquote><p>
Server Application Unavailable</p>
<p>The web application you are attempting to access on this web server is currently unavailable.</p>
<p>Please hit the "Refresh" button in your web browser to retry your request.</p>
<p>Administrator Note: An error message detailing the cause of this specific request failure can be found in the system event log of the web server.  Please review this log entry to discover what caused this error to occur.</p></blockquote>
<p>
The web leads me far astray.  I did <em>not</em> have anything in the event log.
</p>
<p>
The solution? Give MACHINE/ASPNET permission to my project.  I found this a LOT faster by switching to .NET 1.1 in IIS, and that gave a much more useful error message.  I guess "Server Application Unavailable" is .NET 2's way of crapping its pants.</p>
]]></content:encoded>
			<wfw:commentRss>http://ryepup.unwashedmeme.com/blog/2007/02/14/server-application-unavailable-no-event-log-net-2/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.756 seconds -->

