<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: URL parsing and manipulation in .NET</title>
	<atom:link href="http://damieng.com/blog/2006/07/07/url_parsing_and_manipulation_in_net/feed" rel="self" type="application/rss+xml" />
	<link>http://damieng.com/blog/2006/07/07/url_parsing_and_manipulation_in_net</link>
	<description>A .NET developer in Redmond</description>
	<lastBuildDate>Wed, 10 Mar 2010 22:08:10 -0800</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: guitarpoet</title>
		<link>http://damieng.com/blog/2006/07/07/url_parsing_and_manipulation_in_net#comment-17451</link>
		<dc:creator>guitarpoet</dc:creator>
		<pubDate>Mon, 18 May 2009 06:55:54 +0000</pubDate>
		<guid isPermaLink="false">http://damieng.com/blog/archive/2006/07/07/url_parsing_and_manipulation_in_net.aspx#comment-17451</guid>
		<description>Hello, I think the code has a bug and I had rewrite it like this:
private const string urlDecodeRegex = @&quot;([^:]+)://(([^:@]+)(:([^@]+))?@)?([^:/?#]+)(:([\d]+))?([^?#]+)?(\?([^#]+))?(#(.*))?&quot;;</description>
		<content:encoded><![CDATA[<p>Hello, I think the code has a bug and I had rewrite it like this:<br />
private const string urlDecodeRegex = @&#8221;([^:]+)://(([^:@]+)(:([^@]+))?@)?([^:/?#]+)(:([\d]+))?([^?#]+)?(\?([^#]+))?(#(.*))?&#8221;;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ziv Rozzbach</title>
		<link>http://damieng.com/blog/2006/07/07/url_parsing_and_manipulation_in_net#comment-9578</link>
		<dc:creator>Ziv Rozzbach</dc:creator>
		<pubDate>Sun, 05 Oct 2008 15:00:33 +0000</pubDate>
		<guid isPermaLink="false">http://damieng.com/blog/archive/2006/07/07/url_parsing_and_manipulation_in_net.aspx#comment-9578</guid>
		<description>Nice, but it does not do one thing: splitting the host from the domain
so if I enter reag123.afsda123.ukdomain.co.uk it will return me: ukdomain.co.uk

Anyone have any idea how can I do it ?</description>
		<content:encoded><![CDATA[<p>Nice, but it does not do one thing: splitting the host from the domain<br />
so if I enter reag123.afsda123.ukdomain.co.uk it will return me: ukdomain.co.uk</p>
<p>Anyone have any idea how can I do it ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: MrToes</title>
		<link>http://damieng.com/blog/2006/07/07/url_parsing_and_manipulation_in_net#comment-8461</link>
		<dc:creator>MrToes</dc:creator>
		<pubDate>Mon, 12 May 2008 16:09:24 +0000</pubDate>
		<guid isPermaLink="false">http://damieng.com/blog/archive/2006/07/07/url_parsing_and_manipulation_in_net.aspx#comment-8461</guid>
		<description>It&#039;s also remarkably intolerant of syntax problems. There&#039;s also a problem with the Uri class (in .NET 2.0 Compact Framework at least) where creating it with a string that has leading spaces causes memory corruption. Lovely. We have our own Uri class to fix this (and other) problems. Backward slashes resulting in FormatExceptions is another one that comes to mind. Quite possibly all this is fixed in new shiny .NET versions.

So, how long is it till V-day? :)</description>
		<content:encoded><![CDATA[<p>It&#8217;s also remarkably intolerant of syntax problems. There&#8217;s also a problem with the Uri class (in .NET 2.0 Compact Framework at least) where creating it with a string that has leading spaces causes memory corruption. Lovely. We have our own Uri class to fix this (and other) problems. Backward slashes resulting in FormatExceptions is another one that comes to mind. Quite possibly all this is fixed in new shiny .NET versions.</p>
<p>So, how long is it till V-day? :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Damien Guard</title>
		<link>http://damieng.com/blog/2006/07/07/url_parsing_and_manipulation_in_net#comment-8394</link>
		<dc:creator>Damien Guard</dc:creator>
		<pubDate>Sat, 03 May 2008 10:34:48 +0000</pubDate>
		<guid isPermaLink="false">http://damieng.com/blog/archive/2006/07/07/url_parsing_and_manipulation_in_net.aspx#comment-8394</guid>
		<description>Thanks for spotting and figuring that out Ross - I must have broken it during the reformatting exercise when I switched to this theme.

[)amien</description>
		<content:encoded><![CDATA[<p>Thanks for spotting and figuring that out Ross &#8211; I must have broken it during the reformatting exercise when I switched to this theme.</p>
<p>[)amien</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Russ</title>
		<link>http://damieng.com/blog/2006/07/07/url_parsing_and_manipulation_in_net#comment-8388</link>
		<dc:creator>Russ</dc:creator>
		<pubDate>Fri, 02 May 2008 17:02:32 +0000</pubDate>
		<guid isPermaLink="false">http://damieng.com/blog/archive/2006/07/07/url_parsing_and_manipulation_in_net.aspx#comment-8388</guid>
		<description>I found the problem, it&#039;s in the regular expression.. Here&#039;s the new line.

private const string urlDecodeRegex = @&quot;([^:]+)://(([^:@]+)(:([^@]+))?@)?([^:/?#]+)(:([d]+))?([^?#]+)?(\?([^#]+))?(#(.*))?&quot;;</description>
		<content:encoded><![CDATA[<p>I found the problem, it&#8217;s in the regular expression.. Here&#8217;s the new line.</p>
<p>private const string urlDecodeRegex = @&#8221;([^:]+)://(([^:@]+)(:([^@]+))?@)?([^:/?#]+)(:([d]+))?([^?#]+)?(\?([^#]+))?(#(.*))?&#8221;;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Russ</title>
		<link>http://damieng.com/blog/2006/07/07/url_parsing_and_manipulation_in_net#comment-8387</link>
		<dc:creator>Russ</dc:creator>
		<pubDate>Fri, 02 May 2008 16:52:15 +0000</pubDate>
		<guid isPermaLink="false">http://damieng.com/blog/archive/2006/07/07/url_parsing_and_manipulation_in_net.aspx#comment-8387</guid>
		<description>This works well, but any attempts that I make to use an imported query string dont seem to work. I can build a querystring and export ok, but importing one fails.

Is there a download of this as a .cs class file?</description>
		<content:encoded><![CDATA[<p>This works well, but any attempts that I make to use an imported query string dont seem to work. I can build a querystring and export ok, but importing one fails.</p>
<p>Is there a download of this as a .cs class file?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Damien Guard</title>
		<link>http://damieng.com/blog/2006/07/07/url_parsing_and_manipulation_in_net#comment-8221</link>
		<dc:creator>Damien Guard</dc:creator>
		<pubDate>Fri, 11 Apr 2008 09:56:33 +0000</pubDate>
		<guid isPermaLink="false">http://damieng.com/blog/archive/2006/07/07/url_parsing_and_manipulation_in_net.aspx#comment-8221</guid>
		<description>@Mike: Well you could but if that&#039;s all you want you may as well just grab the string up to the final / with  urlString.Substring(0,urlString.LastIndexOf(&#039;/&#039;)-1)

[)amien</description>
		<content:encoded><![CDATA[<p>@Mike: Well you could but if that&#8217;s all you want you may as well just grab the string up to the final / with  urlString.Substring(0,urlString.LastIndexOf(&#8216;/&#8217;)-1)</p>
<p>[)amien</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike</title>
		<link>http://damieng.com/blog/2006/07/07/url_parsing_and_manipulation_in_net#comment-6866</link>
		<dc:creator>Mike</dc:creator>
		<pubDate>Mon, 17 Mar 2008 18:46:36 +0000</pubDate>
		<guid isPermaLink="false">http://damieng.com/blog/archive/2006/07/07/url_parsing_and_manipulation_in_net.aspx#comment-6866</guid>
		<description>If I had this: http://damieng.com/blog/2006/07/07/URL_parsing_and_manipulation_in_.NET

How could I get just this part?
http://damieng.com/blog/2006/07/07</description>
		<content:encoded><![CDATA[<p>If I had this: <a href="http://damieng.com/blog/2006/07/07/URL_parsing_and_manipulation_in_.NET" rel="nofollow">http://damieng.com/blog/2006/07/07/URL_parsing_and_manipulation_in_.NET</a></p>
<p>How could I get just this part?<br />
<a href="http://damieng.com/blog/2006/07/07" rel="nofollow">http://damieng.com/blog/2006/07/07</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Fabian</title>
		<link>http://damieng.com/blog/2006/07/07/url_parsing_and_manipulation_in_net#comment-1538</link>
		<dc:creator>Fabian</dc:creator>
		<pubDate>Wed, 19 Jul 2006 21:39:27 +0000</pubDate>
		<guid isPermaLink="false">http://damieng.com/blog/archive/2006/07/07/url_parsing_and_manipulation_in_net.aspx#comment-1538</guid>
		<description>Great job, thanks!</description>
		<content:encoded><![CDATA[<p>Great job, thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Damien Guard</title>
		<link>http://damieng.com/blog/2006/07/07/url_parsing_and_manipulation_in_net#comment-1537</link>
		<dc:creator>Damien Guard</dc:creator>
		<pubDate>Tue, 18 Jul 2006 14:10:20 +0000</pubDate>
		<guid isPermaLink="false">http://damieng.com/blog/archive/2006/07/07/url_parsing_and_manipulation_in_net.aspx#comment-1537</guid>
		<description>The Uri class in .NET is pretty useless.  It doesn&#039;t include username/password properties, the query part is a string instead of a collection of name/value pairs etc.&lt;br /&gt;&lt;br /&gt;[)amien</description>
		<content:encoded><![CDATA[<p>The Uri class in .NET is pretty useless.  It doesn&#8217;t include username/password properties, the query part is a string instead of a collection of name/value pairs etc.</p>
<p>[)amien</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Haacked</title>
		<link>http://damieng.com/blog/2006/07/07/url_parsing_and_manipulation_in_net#comment-1536</link>
		<dc:creator>Haacked</dc:creator>
		<pubDate>Tue, 18 Jul 2006 07:22:13 +0000</pubDate>
		<guid isPermaLink="false">http://damieng.com/blog/archive/2006/07/07/url_parsing_and_manipulation_in_net.aspx#comment-1536</guid>
		<description>I just checked and Uri in .NET 2.0 is serializable.</description>
		<content:encoded><![CDATA[<p>I just checked and Uri in .NET 2.0 is serializable.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Haacked</title>
		<link>http://damieng.com/blog/2006/07/07/url_parsing_and_manipulation_in_net#comment-1535</link>
		<dc:creator>Haacked</dc:creator>
		<pubDate>Tue, 18 Jul 2006 07:18:18 +0000</pubDate>
		<guid isPermaLink="false">http://damieng.com/blog/archive/2006/07/07/url_parsing_and_manipulation_in_net.aspx#comment-1535</guid>
		<description>You should consider making it Serializable.  THat&#039;s one issue I&#039;ve had with the existing Uri class.</description>
		<content:encoded><![CDATA[<p>You should consider making it Serializable.  THat&#8217;s one issue I&#8217;ve had with the existing Uri class.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John Rummell</title>
		<link>http://damieng.com/blog/2006/07/07/url_parsing_and_manipulation_in_net#comment-1534</link>
		<dc:creator>John Rummell</dc:creator>
		<pubDate>Tue, 11 Jul 2006 07:43:50 +0000</pubDate>
		<guid isPermaLink="false">http://damieng.com/blog/archive/2006/07/07/url_parsing_and_manipulation_in_net.aspx#comment-1534</guid>
		<description>Excellent.  Thank you!</description>
		<content:encoded><![CDATA[<p>Excellent.  Thank you!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John Rummell</title>
		<link>http://damieng.com/blog/2006/07/07/url_parsing_and_manipulation_in_net#comment-1532</link>
		<dc:creator>John Rummell</dc:creator>
		<pubDate>Tue, 11 Jul 2006 07:25:52 +0000</pubDate>
		<guid isPermaLink="false">http://damieng.com/blog/archive/2006/07/07/url_parsing_and_manipulation_in_net.aspx#comment-1532</guid>
		<description>I linked from DotNetKicks.  This is cool.  How would I use this to grab the URL without the QueryString?</description>
		<content:encoded><![CDATA[<p>I linked from DotNetKicks.  This is cool.  How would I use this to grab the URL without the QueryString?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Damien Guard</title>
		<link>http://damieng.com/blog/2006/07/07/url_parsing_and_manipulation_in_net#comment-1533</link>
		<dc:creator>Damien Guard</dc:creator>
		<pubDate>Mon, 10 Jul 2006 21:34:24 +0000</pubDate>
		<guid isPermaLink="false">http://damieng.com/blog/archive/2006/07/07/url_parsing_and_manipulation_in_net.aspx#comment-1533</guid>
		<description>Yeah sorry there are no usage samples - I did write a few but my blog software started activating the anti-spam on me :D
To get the current URL:
&lt;pre&gt;&lt;code&gt;&lt;code&gt;URL myURL = &lt;strong&gt;new&lt;/strong&gt; URL(Page.Request.Url.ToString());&lt;/code&gt;&lt;/pre&gt;
You could remove all the query string with:
&lt;pre&gt;&lt;code&gt;&lt;code&gt;myURL.QueryString = &quot;&quot;;&lt;/code&gt;&lt;/pre&gt;
Alternatively if you just wanted to set one item - say a customerID you would normally have to hope it didn&#039;t exist and add it - taking note to append &quot;&amp;&quot; or &quot;?&quot; depending on if there are other query values. With this class you can just;
&lt;pre&gt;&lt;code&gt;&lt;code&gt;myURL.Query[&quot;CustomerID&quot;] = &quot;1&quot;;&lt;/code&gt;&lt;/pre&gt;
Oh, and to write our your hyperlink you&#039;d do something like;
&lt;pre&gt;&lt;code&gt;&lt;code&gt;nextCustomerLink.Href = myURL.FullURL;&lt;/code&gt;&lt;/pre&gt;
&lt;em&gt;[)amien&lt;/em&gt;</description>
		<content:encoded><![CDATA[<p>Yeah sorry there are no usage samples &#8211; I did write a few but my blog software started activating the anti-spam on me :D<br />
To get the current URL:</p>
<pre><code></code><code>URL myURL = <strong>new</strong> URL(Page.Request.Url.ToString());</code></pre>
<p>You could remove all the query string with:</p>
<pre><code></code><code>myURL.QueryString = "";</code></pre>
<p>Alternatively if you just wanted to set one item - say a customerID you would normally have to hope it didn't exist and add it - taking note to append "&amp;" or "?" depending on if there are other query values. With this class you can just;</p>
<pre><code></code><code>myURL.Query["CustomerID"] = "1";</code></pre>
<p>Oh, and to write our your hyperlink you'd do something like;</p>
<pre><code></code><code>nextCustomerLink.Href = myURL.FullURL;</code></pre>
<p><em>[)amien</em></p>
]]></content:encoded>
	</item>
</channel>
</rss>
