<?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>Ramble &#187; ASP.NET</title>
	<atom:link href="http://www.alterzone.net/blog/category/aspnet/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.alterzone.net/blog</link>
	<description>Where the Future Never Looks the Same Way Twice</description>
	<lastBuildDate>Mon, 17 Jan 2011 02:43:01 +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>ASP.NET and Its Discontents</title>
		<link>http://www.alterzone.net/blog/2007/12/14/aspnet-and-its-discontents-3/</link>
		<comments>http://www.alterzone.net/blog/2007/12/14/aspnet-and-its-discontents-3/#comments</comments>
		<pubDate>Fri, 14 Dec 2007 05:05:24 +0000</pubDate>
		<dc:creator>Stephen Tolton</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.alterzone.net/blog/2007/12/14/aspnet-and-its-discontents-3/</guid>
		<description><![CDATA[I like C#. While I prefer languages like Perl and Python, I have to admit that C# is pretty cool. And, with Mono, I could even write nice, happy, FLOSS apps in it, if I like. But, I hate ASP.NET. I am forced to use this abominable framework at work and today I was once [...]]]></description>
			<content:encoded><![CDATA[<p>I like <a href="http://msdn2.microsoft.com/en-us/vcsharp/aa336809.aspx" title="The C# Language">C#</a>. While I prefer languages like <a href="http://www.perl.org/" title="The Perl Directory">Perl</a> and <a href="http://www.python.org/" title="Python Programming Language">Python</a>,
I have to admit that C# is pretty cool. And, with <a href="http://www.mono-project.com/Main_Page" title="Mono Project">Mono</a>, I could
even write nice, happy, FLOSS apps in it, if I like. But, I <em>hate</em>
<a href="http://asp.net/" title="The Official Microsoft ASP.NET Site">ASP.NET</a>.</p>

<p>I am forced to use this abominable framework at work and today I was
once again reminded of why I hate it so much. My biggest problem with
it is that it seems to have been designed without any real thought
put into what <em>Web</em> programming entails. I suppose it sounded like a
great idea at the time to design a framework that mimicked desktop
application development. But, the majority of the serious programming
I have done in my life has in some way touched on the Web, either
directly as a traditional Web application, or using Web-related
protocols. I am a Web native and I don&#8217;t need my framework getting in
my way all the time. Working within the Page model of ASP.NET feels
like both my hands and feet have been shackled while I&#8217;m in the
middle of a competitive sparing match.  Today, I lost the fight.</p>

<p><span id="more-133"></span></p>

<p>On the plus side, I can dive into the <a href="http://msdn.microsoft.com/msdnmag/issues/02/09/HTTPPipelines/" title="HTTP Pipelines, MSDN Magazine">HTTP Pipeline</a>, which
is nice. HTTPModules saved me when I was trying to create a big part
of the next <a href="http://drexel.edu/irt/rmcweb/" title="Rich Media Syndication System">RMCP</a> release. But, still, it wasn&#8217;t as easy as if I
just used Python with <a href="http://www.djangoproject.com/" title="Django Web Framework">Django</a> or <a href="http://www.rubyonrails.org/" title="Ruby on Rails">Ruby on Rails</a>, or even,
sometimes, straight up Perl <a href="http://www.wiley.com/legacy/compbooks/stein/" title="Official Guide to Programming with CGI.pm">CGI.pm</a>! Today, I encountered a
particularly nasty bug/feature of .NET 2.0 that has caused
development of a simple implementation of an <a href="http://www.apple.com/itunesu" title="iTunes U">iTunes U</a> login system
grind to a screeching halt.</p>

<p>I have a form, lets call it <code>Login.aspx</code>, that iTunes U will redirect
users to when they try to access an iTunes U page that is not
public (i.e., requires you to be authenticated).  So, their system
simply causes iTunes to launch the users browser and hands it a 
URL with a simple query string like 
<code>http://mydomain.edu/Login.aspx?destination={$SomeITunesUrl}</code>.</p>

<p>Simple, right? My <code>Login.aspx</code> page displays a Login form and in the
background will check LDAP to authenticate the user and then a custom
database to authorize the user and decide what specific iTunes U
credentials are assigned. Then, there is this whole iTunes U
authorization algorithm that I ported today from their Java example
that just builds a HTTP request with a special authorization token
that is sent to iTunes U and what I get back is a special HTML page
that I am supposed to forward back to the user&#8217;s browser, wherein the
user&#8217;s browser will open back up iTunes and, as if by magic, the user
will be logged into iTunes U.</p>

<p>The problem comes after I have the HTML page.  How do I get 
that page back to the user?  You can&#8217;t do it from within a
regular ASPX page, as far as I can tell.  Because of the way the
HTTP Pipeline processing works for ASPX pages, no matter what I
do, even if I directly mess with <code>Application.Response</code> within
the page, it will be overridden by the time the HTTP pipeline
event, <code>OnEndRequest()</code>, is called.  So, what I want to do is just
redirect the request, after I have done the authentication and
authorization, to a custom <a href="http://msdn2.microsoft.com/en-us/library/5c67a8bd(VS.71).aspx" title="HttpHandlers">HttpHandler</a> that will do the actual
request to iTunes U and return the HTML to the user, since within
the handler, I can completely control the HTTP response sent
back to the client.  Okay, still with me?  Great.</p>

<p>The problem is that I need do the transfer to the handler while
passing it some context variables, specifically, information about
the user and the destination URL within iTunes U. So, I thought, hey,
that&#8217;s a perfect job for <code>Server.Transfer()</code>! <strong>WRONG!</strong> If you try
it, you get a nice error message that explains nothing.</p>

<p>Even though the <a href="http://msdn2.microsoft.com/en-us/library/8z9e2zxx.aspx" title="HttpServerUtility.Transfer Method">documentation</a> explicitly provides a method
signature that would lead one to believe that you can transfer to a
HttpHandler, you apparently, can&#8217;t. Well, at least not unless it is
another Page handle. So, Microsoft says that this is by
<a href="http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=102401" title="Error execute child request... exception">design</a>, but then why have it in the documentation!</p>

<p>I wasted at least half of my day on this and now I am going to 
need to figure out how to do this completely differently.  I
think this <code>Server.Transfer()</code> &#8220;feature&#8221; should be considered a
bug.  I could use <code>Response.Redirect()</code>, but that doesn&#8217;t help
me because I need to transfer context items and I can&#8217;t do that
with a redirect.  I can&#8217;t pass the data as a query string because
then you&#8217;d be able to just see the query string params and
bypass the whole login form!  I guess I could build some elaborate
system that encrypts my data as a string with a time stamp that is
decrypted by the handler, but I shouldn&#8217;t need to do something
like that for such a simple task.</p>

<p>Plain and simple: ASP.NET drives me crazy. There are just things that
seem easy to do in other frameworks and languages, but force one to
jump through incredible numbers of poorly documented hoops to do in
ASP.NET. It is sucking the life out of me. Maybe v3.0/3.5 will help?
I don&#8217;t even care. I&#8217;m so sick of ASP.NET and .NET in general, that I
just want to dump the whole enterprise and I would, if only I could.</p>

<p>Oh well, maybe I&#8217;ll have better luck tomorrow.  If anyone has
any ideas on a workaround to the <code>Server.Transfer()</code> with 
HttpHandler problem, let me know.  My frayed nerves would
appreciate it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.alterzone.net/blog/2007/12/14/aspnet-and-its-discontents-3/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

