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.

1

1 Answer 1

2

Request.Url.GetLeftPart(UriPartial.Path)

Sign up to request clarification or add additional context in comments.

1 Comment

for some reason Request.Url.GetLeftPart(UriPartial.Path) gives me http link instead https link. I don't know what i am missing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.