Avatar ·

How to get the current page URL in ASP.NET C#?

Hello everyone! I'm a beginner in C# and ASP.NET, and I have a seemingly simple problem. I need to get the full address of the current page the user is on, for example, to pass it to a feedback link or save it to a log. I've tried several options, but none work as I expected. Here's what I tried: ```csharp // Attempt 1: Just Request.Url string url = Request.Url.ToString(); // Returns something strange, like http://localhost:5000/Default.aspx, but without parameters // Attempt 2: HttpContext.Current string currentUrl = HttpContext.Current.Request.Url.AbsoluteUri; // Seems to work, but sometimes returns null // Attempt 3: Using Page.Request string pageUrl = Page.Request.Url.ToString(); // Error: "Page" does not exist in the current context ```