Fetching a segment of the URL in the address bar
<p>This is what I tried:</p>

<pre><code>string myURL= "http://mysite.com/articles/healthrelated";
String idStr = myURL.Substring(myURL.LastIndexOf('/') + 1);
</code></pre>

<p>I need to fetch "healthrelated" ie the text after the last slash in the URL. Now the problem is that my URL can also be like :</p>

<pre><code>"http://mysite.com/articles/healthrelated/"   
</code></pre>

<p>ie "a Slash" at the end of that text too. Now the last slash becomes the one AFTER "healthrelated" and so the result I get using </p>

<pre><code>String idStr = myURL.Substring(myURL.LastIndexOf('/') + 1);
</code></pre>

<p>is empty string..</p>

<p>what should my code be like so I always get that text "healthrelated" no matter if there's a slash in the end or not. I just need to fetch that text somehow.</p>
