StevieB
StevieB

Reputation: 6543

ASP.NET Removing Querystring from friendly URL

Hey I am trying to remove a querystring from a friendly URL i.e I have

/who-we-are/our-people.html?linkidentifier=id&itemid=42

And I want to change the above to

/who-we-are/our-people.html

How can I remove anything after the .html

Upvotes: 0

Views: 1460

Answers (3)

immutabl
immutabl

Reputation: 6903

You need to use the Request's Path property - this article should give you everything you need: Making Sense of ASP.NET Paths

Upvotes: 0

James McCormack
James McCormack

Reputation: 9954

Fastest way to do it reliably is to use the System.Uri class:

string pathOnly = new Uri("http://whatever.com/who-we-are/our-people.html?linkidentifier=id&itemid=42").AbsolutePath;

Upvotes: 2

Pankaj Agarwal
Pankaj Agarwal

Reputation: 11309

You need to do URL rewriting.

Here you can find more about this click here

Upvotes: 0

Related Questions