3

How to get current page URL excluding query string parameters. My URL is like this https://mywebsite.com/myproject/detailspage?id=2812

I want to get only https://mywebsite.com/myproject/detailspage.

I tried this but not helped.

string path = HttpContext.Current.Request.Url.AbsolutePath;
string url = HttpContext.Current.Request.Url.AbsoluteUri;

Please any suggestions.

jina
  • 115
  • 11
  • 3
    Possible duplicate of [Get url without querystring](https://stackoverflow.com/questions/4630249/get-url-without-querystring) – Nived Mar 20 '19 at 15:59

1 Answers1

2

Request.Url.GetLeftPart(UriPartial.Path)

Nived
  • 1,804
  • 1
  • 15
  • 29
  • for some reason Request.Url.GetLeftPart(UriPartial.Path) gives me http link instead https link. I don't know what i am missing. – jina Mar 20 '19 at 18:36