开发者

ASP.NET Removing Querystring from friendly URL

开发者 https://www.devze.com 2023-03-06 16:36 出处:网络
Hey I am trying to remove a querystring from a friendly URL i.e I have /who-we-are/our-people.html?linkident开发者_开发百科ifier=id&itemid=42

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

/who-we-are/our-people.html?linkident开发者_开发百科ifier=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


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;


You need to do URL rewriting.

Here you can find more about this click here


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

0

精彩评论

暂无评论...
验证码 换一张
取 消