Getting Current Url with C#

Hey guys

I have a bit of a problem. We have an SEO guy here, that says I must put a 301 redirect on http://www.domain.com/videos/page.aspx to go to /videos/ and IIS has page.aspx as the default start document. Which works fine.

The problem is, even if ur on page.aspx it must redirect to that url and remove the page.aspx part.

So my question is, how do I check if the user is on:
/videos/page.aspx
or
/vidoes/

which is essentially the same page?

Request.Url always gets page.aspx weather its in the url or not and the redirect puts the page into a continuous loop.

Thanks for any help/feedback

hello

hello, i’m not sure , it this what u want?

Request.ServerVariables.Get(“PATH_INFO”);

http://www.aspcode.net/List-of-RequestServerVariables.aspx

Are you running IIS7? If so you can use the IIS7 rewrite module with something like this:

<rule name="Default Document" stopProcessing="true">
 <match url="(.*)page.aspx"/>
 <action type="Redirect" url="{R:1}" redirectType="Permanent"/>
</rule>

Gives the same result as Request.Url

Unfortunately not.

Im beginning to think that this is a bit of an overkill, doubt its gona make such a difference to google rankings doing this…

The only other option I can think of is ISAPIRewrite

Im beginning to think that this is a bit of an overkill, doubt its gona make such a difference to google rankings doing this…
It depends on who you ask :wink: maybe it’s worth asking in the Search Engine Optimisation Forum

Really, not much makes a difference in google rankings save real, quality backlinks. You know, the kind of stuff you get by having quality content and a site people want to visit. SEO types don’t believe that because they would then have to do real work. I think the SEO point he is hitting on is that you technically have duplicate content going on as /video/ and /video/page.aspx are going to the same place.

Anyhow, shouldn’t be too hard to make the 301 redirect work, what you want to look at is HttpRequest.Url.Segments – it returns an exploded array of all the parts. Should be able to find the entry that ends with .aspx and trim back accordingly pretty easily.