<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" version="2.0">

<channel>
	<title>Gath Adams</title>
	
	<link>http://gathadams.com</link>
	<description>Make it. Spend it.</description>
	<pubDate>Sun, 16 Aug 2009 23:13:21 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/GathAdams" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="gathadams" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">GathAdams</feedburner:emailServiceId><feedburner:feedburnerHostname xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">http://feedburner.google.com</feedburner:feedburnerHostname><item>
		<title>Add ‘Tweet This’ button to your Asp.Net site. Twitter + Bit.ly url shortening</title>
		<link>http://gathadams.com/2009/08/08/add-tweet-this-button-to-your-aspnet-site-twitter-bitly-url-shortening/</link>
		<comments>http://gathadams.com/2009/08/08/add-tweet-this-button-to-your-aspnet-site-twitter-bitly-url-shortening/#comments</comments>
		<pubDate>Sat, 08 Aug 2009 21:47:12 +0000</pubDate>
		<dc:creator>Gath</dc:creator>
		
		<category><![CDATA[APIs]]></category>

		<category><![CDATA[Coding]]></category>

		<category><![CDATA[Twitter]]></category>

		<category><![CDATA[asp.net]]></category>

		<category><![CDATA[bit.ly]]></category>

		<category><![CDATA[vb.net]]></category>

		<guid isPermaLink="false">http://gathadams.com/?p=100</guid>
		<description><![CDATA[Adding your own &#8216;Tweet This&#8217; buttons so your visitors can post to twitter (complete with URL shortening using Bit.ly) is really easy.
Just add a page &#8216;twitter.aspx&#8217; to your site and remove all the HTML from the page.
Add this code:

Imports System.Net

Partial Public Class Twitter

    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        If [...]]]></description>
			<content:encoded><![CDATA[<p>Adding your own &#8216;Tweet This&#8217; buttons so your visitors can post to twitter (complete with URL shortening using Bit.ly) is really easy.</p>
<p>Just add a page &#8216;twitter.aspx&#8217; to your site and remove all the HTML from the page.</p>
<p>Add this code:</p>
<pre style="border: 1px solid black; overflow: auto; margin-bottom: 10px; width: 100%; height: 100%;"><code>
Imports System.Net

Partial Public Class Twitter

    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        If Request.QueryString("url") &lt;&gt; "" And Request.QueryString("com") &lt;&gt; "" Then

            TweetThis(Request.QueryString("url"), Request.QueryString("com"))

        End If

    End Sub

    Private Sub TweetThis(ByVal sIWTFURL As String, ByVal sComment As String)

        Dim sShortURL As String

        Dim sFullTweet As String

        sShortURL = ShortenURL(sIWTFURL)

        sFullTweet = sComment &amp; " - " &amp; sShortURL

        SentToTwitter(sFullTweet)

    End Sub

    Private Function ShortenURL(ByVal sURL As String) As String

        Dim sJSON As String

        Dim oWebClient As New WebClient

        Dim sBitlyURL As String

        Dim sShortURL As String

        sBitlyURL = "http://api.bit.ly/shorten?version=2.0.1&amp;longUrl=" &amp; Server.UrlEncode(sURL) &amp; "&amp;login=bitlyapidemo&amp;apiKey=R_0da49e0a9118ff35f52f629d2d71bf07"

        sJSON = oWebClient.DownloadString(sBitlyURL)

        sJSON = Mid$(sJSON, InStr(sJSON, Chr(34) &amp; "shortUrl" &amp; Chr(34)) + 9)

        Do While sJSON.ToLower.StartsWith("http://") = False

            sJSON = Mid$(sJSON, 2)

        Loop

        sShortURL = sJSON.Split(Chr(34))(0)

        ShortenURL = sShortURL

    End Function

    Private Sub SentToTwitter(ByVal sComments As String)

        Dim sURL As String

        sURL = "http://twitter.com/home/?status=" &amp; HttpUtility.UrlEncode(sComments)

        Response.Redirect(sURL, False)

    End Sub

End Class
</code></pre>
<p>Note: I am using the default Bit.ly login in the example, you should sign up for your own bit.ly account so you can track usage of your links.</p>
<p>Now you just need to add some javascript to your html pages:</p>
<pre style="border: 1px solid black; overflow: auto; margin-bottom: 10px; width: 100%; height: 100%;">
<code>
&lt;a href="#" onClick='javascript:PostToTwitter()'&gt;Tweet This&lt;/a&gt;

&lt;script&gt;
function PostToTwitter()
{
var sTweet = 'This is the default text that will appear in the tweet';
var ShareURL = window.location.href;

window.open('http://yoursite.com/twitter.aspx?url='+encodeURIComponent(ShareURL)+'&#038;com='+encodeURIComponent(sTweet));
return false;
}
&lt;/script&gt;
</code>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://gathadams.com/2009/08/08/add-tweet-this-button-to-your-aspnet-site-twitter-bitly-url-shortening/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Convert www. to non www. urls for ASP.Net websites</title>
		<link>http://gathadams.com/2009/06/16/convert-www-to-non-www-urls-for-aspnet/</link>
		<comments>http://gathadams.com/2009/06/16/convert-www-to-non-www-urls-for-aspnet/#comments</comments>
		<pubDate>Wed, 17 Jun 2009 03:11:07 +0000</pubDate>
		<dc:creator>Gath</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://gathadams.com/?p=93</guid>
		<description><![CDATA[Ok, redirecting your www. urls to non www. through IIS is a total pain. Using a url rewriter is a good option - but not always available in shared hosting. Here is a quick method if you have a small ASP.Net site or are using master pages.
Just add this code to the Page_Load sub in [...]]]></description>
			<content:encoded><![CDATA[<p>Ok, redirecting your www. urls to non www. through IIS is a total pain. Using a url rewriter is a good option - but not always available in shared hosting. Here is a quick method if you have a small ASP.Net site or are using master pages.</p>
<p>Just add this code to the Page_Load sub in the master page, or to every page if you aren&#8217;t using master pages.</p>
<pre style="border: 1px solid black; overflow: auto; margin-bottom: 10px; width: 100%; height: 100%;"><code>
        If Not IsPostBack Then

            'redirect www. to non www.

            If LCase(Request.Url.AbsoluteUri).StartsWith("http://www.") = True Then

                Response.Status = "301 Moved Permanently"

                Dim sNewLocation As String

                sNewLocation = "http://" &amp; Mid$(Request.Url.AbsoluteUri, 12)

                If LCase(sNewLocation).EndsWith("/default.aspx") Then

                    sNewLocation = Left$(sNewLocation, Len(sNewLocation) - 13)

                End If

                Response.AddHeader("Location", sNewLocation)

                Exit Sub

            End If

        End If

</code></pre>
<p>the code removes the www. and does a simple 301 redirect, while preserving case etc in the new url.</p>
<p>Come to think of it, now that Google can follow javascript redirects, you could add this code as a javascript sub to your pages. Anyone want to do a live test on their site? <img src='http://gathadams.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://gathadams.com/2009/06/16/convert-www-to-non-www-urls-for-aspnet/feed/</wfw:commentRss>
		</item>
		<item>
		<title>MS Bing integrates Travel with their search engine</title>
		<link>http://gathadams.com/2009/06/04/ms-bing-integrates-travel-with-their-search-engine/</link>
		<comments>http://gathadams.com/2009/06/04/ms-bing-integrates-travel-with-their-search-engine/#comments</comments>
		<pubDate>Fri, 05 Jun 2009 03:10:38 +0000</pubDate>
		<dc:creator>Gath</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://gathadams.com/?p=91</guid>
		<description><![CDATA[
For Travel Meta Search engines, this doesn&#8217;t seem like good news&#8230;
Microsoft bought FareCast in April 09, and now it is helping power Bing Travel. I haven&#8217;t seen the travel link on the Australian version of Bing, but I am guessing that it won&#8217;t be long. Not that I really care what Bing does, but if [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://gathadams.com/Pics/bing.jpg" alt="" /></p>
<p>For Travel Meta Search engines, this doesn&#8217;t seem like good news&#8230;</p>
<p>Microsoft bought FareCast in April 09, and now it is helping power Bing Travel. I haven&#8217;t seen the travel link on the Australian version of Bing, but I am guessing that it won&#8217;t be long. Not that I really care what Bing does, but if the integrated travel works for Microsoft, then Google may do the same thing. And <i>that</i> would be news. How many travel sites depend on traffic from Google? What if that dried up?</p>
]]></content:encoded>
			<wfw:commentRss>http://gathadams.com/2009/06/04/ms-bing-integrates-travel-with-their-search-engine/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Blog restoration, upgrade to 2.7 and other stuff</title>
		<link>http://gathadams.com/2009/05/29/blog-restoration-upgrade-to-27-and-other-stuff/</link>
		<comments>http://gathadams.com/2009/05/29/blog-restoration-upgrade-to-27-and-other-stuff/#comments</comments>
		<pubDate>Sat, 30 May 2009 00:21:32 +0000</pubDate>
		<dc:creator>Gath</dc:creator>
		
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://gathadams.com/?p=88</guid>
		<description><![CDATA[A little while ago I noticed that my blog was down, and that some of the files in the root directory had been corrupted. I contact my host (BlueFur) and they got back to me after 24 hours to say they had fixed the probem, and that all was good.
And they had, kind of.
They had [...]]]></description>
			<content:encoded><![CDATA[<p>A little while ago I noticed that my blog was down, and that some of the files in the root directory had been corrupted. I contact my host (BlueFur) and they got back to me after 24 hours to say they had fixed the probem, and that all was good.</p>
<p>And they had, kind of.</p>
<p>They had restored the blog from a backup made over a year ago. Great going. That&#8217;ll teach me to rely on hosting backups, rather than do my own. Luckily I was able to get most of the posts from google cache, but all the comments made in the last 12 months were lost.</p>
<p>And I&#8217;ve finally rejoined society by upgrading to Wordpress 2.7 (up from 2.1). Finally, my posts are being saved automatically&#8230;</p>
<p>So now everything is in order. Time for some more posts!</p>
]]></content:encoded>
			<wfw:commentRss>http://gathadams.com/2009/05/29/blog-restoration-upgrade-to-27-and-other-stuff/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Star Wars - By someone that hasn’t seen it</title>
		<link>http://gathadams.com/2009/03/03/star-wars-by-someone-that-hasnt-seen-it/</link>
		<comments>http://gathadams.com/2009/03/03/star-wars-by-someone-that-hasnt-seen-it/#comments</comments>
		<pubDate>Wed, 04 Mar 2009 08:00:00 +0000</pubDate>
		<dc:creator>Gath</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[comedy]]></category>

		<category><![CDATA[star wars]]></category>

		<guid isPermaLink="false">http://gathadams.com/2009/03/03/star-wars-by-someone-that-hasnt-seen-it/</guid>
		<description><![CDATA[This is the bestâ€¦


Star Wars: Retold (by someone who hasnâ€™t seen it) from Joe Nicolosi on Vimeo.This post brought to you by WeGotDomain.com - Over 10,000 Aged domains for sale!Related posts:

We Got Domain - over 10,000 aged domains for sale

]]></description>
			<content:encoded><![CDATA[<p>This is the bestâ€¦</p>
<p><embed src="http://vimeo.com/moogaloop.swf?clip_id=2809991&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="400" height="225"></embed><br />
<br />
<a href="http://vimeo.com/2809991">Star Wars: Retold (by someone who hasnâ€™t seen it)</a> from <a href="http://vimeo.com/user759504">Joe Nicolosi</a> on <a href="http://vimeo.com">Vimeo</a>.<span style="color: #aaaaaa">This post brought to you by <a href="http://wegotdomain.com">WeGotDomain.com</a> - Over 10,000 Aged domains for sale!</span><strong>Related posts:</strong></p>
<ol>
<li><a href="http://gathadams.com/2008/03/12/we-got-domain-over-10000-aged-domains-for-sale/" rel="bookmark" title="Permanent Link: We Got Domain - over 10,000 aged domains for sale">We Got Domain - over 10,000 aged domains for sale</a></li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://gathadams.com/2009/03/03/star-wars-by-someone-that-hasnt-seen-it/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Copying the contents of one combo box to another</title>
		<link>http://gathadams.com/2009/01/31/copying-the-contents-of-one-combo-box-to-another/</link>
		<comments>http://gathadams.com/2009/01/31/copying-the-contents-of-one-combo-box-to-another/#comments</comments>
		<pubDate>Sun, 01 Feb 2009 08:00:00 +0000</pubDate>
		<dc:creator>Gath</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[jquery]]></category>

		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://gathadams.com/2009/01/31/copying-the-contents-of-one-combo-box-to-another/</guid>
		<description><![CDATA[Quick code tip on how to copy the contents of a combo box (HTML Select) to another. Using JQuery, of course.

$(&#8221;#NewCombo&#8221;).html($(&#8221;#OriginalCombo&#8221;).html());

I use this for forms with several date pickers, country pickers etc.
This post brought to you by WeGotDomain.com - Over 10,000 Aged domains for sale!
Related posts:

We Got Domain - over 10,000 aged domains for sale
Cast [...]]]></description>
			<content:encoded><![CDATA[<p>Quick code tip on how to copy the contents of a combo box (HTML Select) to another. Using JQuery, of course.</p>
<p><code><br />
$(&#8221;#NewCombo&#8221;).html($(&#8221;#OriginalCombo&#8221;).html());<br />
</code></p>
<p>I use this for forms with several date pickers, country pickers etc.</p>
<p><span style="color:#AAAAAA">This post brought to you by <a href="http://wegotdomain.com">WeGotDomain.com</a> - Over 10,000 Aged domains for sale!</span></p>
<p><b>Related posts:</b>
<ol>
<li><a href="http://gathadams.com/2008/03/12/we-got-domain-over-10000-aged-domains-for-sale/" rel="bookmark" title="Permanent Link: We Got Domain - over 10,000 aged domains for sale">We Got Domain - over 10,000 aged domains for sale</a></li>
<li><a href="http://gathadams.com/2007/03/12/cast-your-net-wiiiide/" rel="bookmark" title="Permanent Link: Cast your net wiiiide">Cast your net wiiiide</a></li>
<li><a href="http://gathadams.com/2008/12/18/copying-cookies-across-domains-in-aspnet/" rel="bookmark" title="Permanent Link: Copying cookies across domains in ASP.Net">Copying cookies across domains in ASP.Net</a></li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://gathadams.com/2009/01/31/copying-the-contents-of-one-combo-box-to-another/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Cool JQuery Plugins</title>
		<link>http://gathadams.com/2009/01/18/cool-jquery-plugins/</link>
		<comments>http://gathadams.com/2009/01/18/cool-jquery-plugins/#comments</comments>
		<pubDate>Mon, 19 Jan 2009 08:00:00 +0000</pubDate>
		<dc:creator>Gath</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[asp.net]]></category>

		<category><![CDATA[asp.net mvc]]></category>

		<category><![CDATA[javascript]]></category>

		<category><![CDATA[jquery]]></category>

		<category><![CDATA[mvc]]></category>

		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://gathadams.com/2009/01/18/cool-jquery-plugins/</guid>
		<description><![CDATA[JQuery - it really is all that &#038; a packet of chips.
Smashing Magazine has just published 45+ New jQuery Techniques For Good User Experience and there is plenty of goodness in there.
For IWantThatHotel.com.au the JQuery plugins that I used were:
BGIFrame
Date Picker
jCarousel (but I am thinking of replacing it with this Content Slider
Lightbox
This post brought to [...]]]></description>
			<content:encoded><![CDATA[<p>JQuery - it really is all that &#038; a packet of chips.</p>
<p>Smashing Magazine has just published <a href="http://www.smashingmagazine.com/2009/01/15/45-new-jquery-techniques-for-a-good-user-experience/">45+ New jQuery Techniques For Good User Experience</a> and there is plenty of goodness in there.</p>
<p>For <a herf="http://iwantthathotel.com.au">IWantThatHotel.com.au</a> the JQuery plugins that I used were:</p>
<p><a href="http://plugins.jquery.com/project/bgiframe">BGIFrame</a><br />
<a href="http://www.kelvinluck.com/assets/jquery/datePicker/v2/demo/">Date Picker</a><br />
<a href="http://sorgalla.com/jcarousel/">jCarousel</a> (but I am thinking of replacing it with this <a href="http://css-tricks.com/creating-a-slick-auto-playing-featured-content-slider/">Content Slider</a><br />
<a href="http://leandrovieira.com/projects/jquery/lightbox/">Lightbox</a></p>
<p><span style="color:#AAAAAA">This post brought to you by <a href="http://wegotdomain.com">WeGotDomain.com</a> - Over 10,000 Aged domains for sale!</span></p>
<p><b>Related posts:</b>
<ol>
<li><a href="http://gathadams.com/2008/03/12/we-got-domain-over-10000-aged-domains-for-sale/" rel="bookmark" title="Permanent Link: We Got Domain - over 10,000 aged domains for sale">We Got Domain - over 10,000 aged domains for sale</a></li>
<li><a href="http://gathadams.com/2008/09/23/integrating-jquery-with-aspnet-a-cool-client-side-alert-box/" rel="bookmark" title="Permanent Link: Integrating JQuery with ASP.net - A Cool Client-side Alert Box">Integrating JQuery with ASP.net - A Cool Client-side Alert Box</a></li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://gathadams.com/2009/01/18/cool-jquery-plugins/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Getting ASP.Net MVC running on IIS6</title>
		<link>http://gathadams.com/2009/01/14/getting-aspnet-mvc-running-on-iis6/</link>
		<comments>http://gathadams.com/2009/01/14/getting-aspnet-mvc-running-on-iis6/#comments</comments>
		<pubDate>Thu, 15 Jan 2009 08:00:00 +0000</pubDate>
		<dc:creator>Gath</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[asp.net]]></category>

		<category><![CDATA[asp.net mvc]]></category>

		<category><![CDATA[iis6]]></category>

		<category><![CDATA[mvc]]></category>

		<guid isPermaLink="false">http://gathadams.com/2009/01/14/getting-aspnet-mvc-running-on-iis6/</guid>
		<description><![CDATA[I have recently finished a new site IWantThatHotel, my first in ASP.Net MVC.
Over the next couple of weeks I will be posting code examples in VB.Net MVC (of which there are hardly any, it seems).
But first, here is a link to 2 posts that were a huge help getting the clean MVC urls running on [...]]]></description>
			<content:encoded><![CDATA[<p>I have recently finished a new site <a href="http://iwantthathotel.com.au">IWantThatHotel</a>, my first in ASP.Net MVC.</p>
<p>Over the next couple of weeks I will be posting code examples in VB.Net MVC (of which there are hardly any, it seems).</p>
<p>But first, here is a link to 2 posts that were a huge help getting the clean MVC urls running on IIS6<br />
<a href="http://blog.codeville.net/2008/07/04/options-for-deploying-aspnet-mvc-to-iis-6/">Deploying ASP.NET MVC to IIS 6</a><br />
Several options are presented - I chose &#8220;Use a wildcard mapping for aspnet_isapi.dll&#8221; (out of the 4 options presented) because I didn&#8217;t want to alter my routes or extensions, and URL rewriting is a pain.</p>
<p>There is a separate post which talks about improving the performance of this method, which is worth implementing:<br />
<a href="http://blog.codeville.net/2008/07/07/overriding-iis6-wildcard-maps-on-individual-directories/">Disabling wildcard mapping on subdirectories</a></p>
<p><span style="color:#AAAAAA">This post brought to you by <a href="http://wegotdomain.com">WeGotDomain.com</a> - Over 10,000 Aged domains for sale!</span></p>
<p>No related posts.</p>
]]></content:encoded>
			<wfw:commentRss>http://gathadams.com/2009/01/14/getting-aspnet-mvc-running-on-iis6/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Allowing special characters (forward slash, hash, asterisk etc) in ASP.Net MVC URL parameters</title>
		<link>http://gathadams.com/2009/01/06/allowing-special-characters-forward-slash-hash-asterisk-etc-in-aspnet-mvc-urls/</link>
		<comments>http://gathadams.com/2009/01/06/allowing-special-characters-forward-slash-hash-asterisk-etc-in-aspnet-mvc-urls/#comments</comments>
		<pubDate>Wed, 07 Jan 2009 08:00:00 +0000</pubDate>
		<dc:creator>Gath</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[asp.net]]></category>

		<category><![CDATA[Coding]]></category>

		<category><![CDATA[mvc]]></category>

		<category><![CDATA[routes]]></category>

		<category><![CDATA[special characters]]></category>

		<category><![CDATA[url]]></category>

		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://gathadams.com/2009/01/06/permanent-link-to-allowing-special-characters-forward-slash-hash-asterisk-etc-in-aspnet-mvc-url-parameters/</guid>
		<description><![CDATA[Iâ€™ve been getting into ASP.Net MVC a lot lately and there is plenty that is good about it.
One thing that is not good is the problems that MVC has when you have a special character (*,/,&#38; etc) in your querystring.
Eg: Say you want to pass the param
url=http://google.com
MVC wonâ€™t like it - â€˜/â€™ is a special [...]]]></description>
			<content:encoded><![CDATA[<p>Iâ€™ve been getting into ASP.Net MVC a lot lately and there is plenty that is good about it.</p>
<p>One thing that is <strong>not</strong> good is the problems that MVC has when you have a special character (*,/,&amp; etc) in your querystring.</p>
<p>Eg: Say you want to pass the param</p>
<p>url=http://google.com</p>
<p>MVC wonâ€™t like it - â€˜/â€™ is a special character reserved as a separator for routes. But standard URL encoding it wonâ€™t work either:</p>
<p>url=http%3A%2F%2Fgoogle.com</p>
<p>MVC will still give a â€˜HTTP Error 400 - Bad Request errorâ€™.</p>
<p>After looking around, it seems this error has been coming up a bit <a href="http://stackoverflow.com/questions/373599/how-to-pass-special-characters-so-aspnet-mvc-can-handle-correctly-query-string">here</a> and <a href="http://stackoverflow.com/questions/240224/double-incomplete-parameter-url-encoding">here</a> and Phil Haack explains why standard encoding wonâ€™t work <a href="http://haacked.com/archive/2008/04/10/upcoming-changes-in-routing.aspx#68032">here</a>.</p>
<p>One answer is to use base 64 encoding on any parameters that might contain the special characters.</p>
<pre style="border: 1px solid black; overflow: auto; margin-bottom: 10px; width: 100%; height: 100%">
<code>
Â Â Â Â Â Â Â Â Public Function MyURLEncode(ByVal sInString As String) As String
Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Dim sInStringNoSpaces As String = sInString.Replace(" ", "")
Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Dim sURLEncoded As String = HttpUtility.UrlEncode(sInString)

Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â If sURLEncoded.Replace("+", "") = sInString.Replace(" ", "") Then
Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Return sURLEncoded
Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Else
Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Return "=" &amp; ToBase64(sInString)
Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â End If
Â Â Â Â Â Â Â Â End Function

Â Â Â Â Â Â Â Â Public Function MyURLDecode(ByVal sEncodedString As String) As String
Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â If sEncodedString.StartsWith("=") = True Then
Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â MyURLDecode = FromBase64(Mid$(sEncodedString, 2))
Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Else
Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â MyURLDecode = sEncodedString.Replace("+", " ")
Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â End If
Â Â Â Â Â Â Â Â End Function

Â Â Â Â Â Â Â Â Private Function ToBase64(ByVal sInString As String) As String
Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Dim btByteArray As Byte()
Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Dim a As New System.Text.ASCIIEncoding()
Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Dim sResult As String

Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â btByteArray = a.GetBytes(sInString)

Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sResult = System.Convert.ToBase64String(btByteArray, 0, btByteArray.Length)
Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sResult = sResult.Replace("+", "-").Replace("/", "_")
Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ToBase64 = sResult
Â Â Â Â Â Â Â Â End Function

Â Â Â Â Â Â Â Â Private Function FromBase64(ByVal sBase64String As String) As String
Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sBase64String = sBase64String.Replace("-", "+").Replace("_", "/")
Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Dim obj As New ASCIIEncoding()
Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â FromBase64 = obj.GetString(Convert.FromBase64String(sBase64String))
Â Â Â Â Â Â Â Â End Function
</code></pre>
<p>Because one of the useful things about MVC is the SEO-friendly URLs, the code doesnâ€™t convert to Base 64 unless it is necessary.</p>
<p>To use these functions, here is a brief code snippet:</p>
<pre style="border: 1px solid black; overflow: auto; margin-bottom: 10px; width: 100%; height: 100%">
<code>
Public Class HotelsController
Â Â Â Â Â Â Â Â Inherits System.Web.Mvc.Controller

Â Â Â Â Â Â Â Â Function SelectHotelList(ByVal City As String, _
Â Â Â Â Â Â Â Â ByVal Location As String)

Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â oSearch = New With {.City = MyURLEncode(City), .Location = MyURLEncode(Location)}
Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Dim oDO As New RouteValueDictionary(oSearch)
Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Return RedirectToAction("List", "Hotels", oDO)
Â Â Â Â Â Â Â Â End Function

Â Â Â Â Â Â Â Â Function List(ByVal City As String, _
Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ByVal Location As String)

Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â City = MyURLDecode(City)
Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Location = MyURLDecode(Location)

	...

Â Â Â Â Â Â Â Â End Function
End Class
</code></pre>
<p><strong>Update:</strong> As Justin pointed out below, â€˜/â€™ is a valid character in the base64 alphabet. I have had a quick read about <a href="http://en.wikipedia.org/wiki/Base64">Modified Base64 for URL</a> which basically replaces â€˜+â€™ and â€˜/â€™ characters with â€˜-â€™ and â€˜_â€™ (I leave the padding â€˜=â€™, but you can remove them if you want). I have updated the code with these changes, however I canâ€™t find a test case that puts â€˜/â€™ into the base64 encoded string - anyone know of one?</p>
<p>Also, the above code only encodes ASCII values, if you want to encode UNICode strings, then swap ASCIIEncoding with UnicodeEncoding.</p>
<p><span style="color: #aaaaaa">This post brought to you by <a href="http://wegotdomain.com">WeGotDomain.com</a> - Over 10,000 Aged domains for sale!</span></p>
<p><strong>Related posts:</strong></p>
<ol>
<li><a href="http://gathadams.com/2009/02/10/seomoz-api-wrapper-in-vbnet/" rel="bookmark" title="Permanent Link: SEOMoz Linkscape API wrapper in VB.Net">SEOMoz Linkscape API wrapper in VB.Net</a></li>
<li><a href="http://gathadams.com/2008/07/31/remove-html-tags-and-javascript-from-pages/" rel="bookmark" title="Permanent Link: Remove HTML tags and Javascript from pages">Remove HTML tags and Javascript from pages</a></li>
<li><a href="http://gathadams.com/2008/11/25/automate-firefox-with-aspnet/" rel="bookmark" title="Permanent Link: Automate FireFox with ASP.net">Automate FireFox with ASP.net</a></li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://gathadams.com/2009/01/06/allowing-special-characters-forward-slash-hash-asterisk-etc-in-aspnet-mvc-urls/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Copying cookies across domains in ASP.Net</title>
		<link>http://gathadams.com/2008/12/18/copying-cookies-across-domains-in-aspnet/</link>
		<comments>http://gathadams.com/2008/12/18/copying-cookies-across-domains-in-aspnet/#comments</comments>
		<pubDate>Fri, 19 Dec 2008 08:00:00 +0000</pubDate>
		<dc:creator>Gath</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[asp.net]]></category>

		<category><![CDATA[c#]]></category>

		<category><![CDATA[Coding]]></category>

		<category><![CDATA[cookies]]></category>

		<category><![CDATA[domains]]></category>

		<category><![CDATA[vb.net]]></category>

		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://gathadams.com/2008/12/18/copying-cookies-across-domains-in-aspnet/</guid>
		<description><![CDATA[
If you logging in to remote sites using HttpWebRequest then you are probably used to supplying a CookieContainer object to keep track of login sessions etc. However, sometimes a login will do a redirect, leaving your cookies referring to the login url and not usable on the next url.
Eg:
Post login details to
http://yourdomain/login
Site redirects (302) to:
http://yourdomain/admin
The [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://gathadams.com/Pics/cookie.gif" style="float: left; padding-right: 10px"></p>
<p>If you logging in to remote sites using HttpWebRequest then you are probably used to supplying a CookieContainer object to keep track of login sessions etc. However, sometimes a login will do a redirect, leaving your cookies referring to the login url and not usable on the next url.</p>
<p><strong>Eg:</strong><br />
Post login details to<br />
http://yourdomain/login<br />
Site redirects (302) to:<br />
http://yourdomain/admin</p>
<p>The login cookie is stuck on http://yourdomain/login and is not used at http://yourdomain/admin, so the login fails.</p>
<p>The key is to set:<br />
WebRequestObject.AllowAutoRedirect = false<br />
in the HttpWebRequest for http://yourdomain/login</p>
<p>Code to copy cookies:</p>
<pre style="border: 1px solid black; overflow: auto; margin-bottom: 10px; width: 100%; height: 100%">
<code>
Dim oOldCookies As New CookieContainer
Dim oNewCookies As New CookieContainer
Dim oOldCookiesCol As New CookieCollection

'Do HttpRequest on http://yourdomain/login, place cookies in oOldCookies
'Remember to set WebRequestObject.AllowAutoRedirect = false

oOldCookiesCollection = oOldCookies.GetCookies(New System.Uri("http://www.olddomain.com"))
For iC = 0 To oOldCookiesCol.Count - 1
&#160;&#160;&#160;&#160; oNewCookies.Add(New Cookie(oOldCookiesCol(iC).Name, oOldCookiesCol(iC).Value, "", "http://www.newdomain.com"))
Next

'Now do HttpRequest on http://yourdomain/admin, using oNewCookies
</code></pre>
<p><span style="color:#AAAAAA">This post brought to you by <a href="http://wegotdomain.com">WeGotDomain.com</a> - Over 10,000 Aged domains for sale!</span></p>
<p><b>Related posts:</b>
<ol>
<li><a href="http://gathadams.com/2008/04/01/easy-cross-domain-cookies-sharing-cookies-between-domains/" rel="bookmark" title="Permanent Link: Easy Cross Domain Cookies (Sharing cookies between domains)">Easy Cross Domain Cookies (Sharing cookies between domains)</a></li>
<li><a href="http://gathadams.com/2007/06/25/how-to-set-third-party-cookies-with-iframe-facebook-applications/" rel="bookmark" title="Permanent Link: How to set third-party cookies with iframe Facebook Applications">How to set third-party cookies with iframe Facebook Applications</a></li>
<li><a href="http://gathadams.com/2008/07/15/opening-a-new-browser-window-with-post-data/" rel="bookmark" title="Permanent Link: Opening a new browser window with POST data">Opening a new browser window with POST data</a></li>
<li><a href="http://gathadams.com/2009/02/10/seomoz-api-wrapper-in-vbnet/" rel="bookmark" title="Permanent Link: SEOMoz Linkscape API wrapper in VB.Net">SEOMoz Linkscape API wrapper in VB.Net</a></li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://gathadams.com/2008/12/18/copying-cookies-across-domains-in-aspnet/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>

