Get current page in C #

For example, if I have http://www.mywebsite.com/about.aspx . Store about.aspx (or any other page we're on) in a variable. It also needs this to work, even if there is information in the URL after the page, such as a query string.

+3
source share
2 answers

A - I suggest you read the ASP.NET documentation VERY carefully. The HttpRequest object, available as a Request property, contains all the information you can get about the request. This includes a path called all parameters, etc.

+3
source

, , .

Uri Path. :

Uri test = new Uri("http://www.microsoft.com/default.aspx?id=7&em=958");            
Console.WriteLine(Path.GetFileName(test.AbsolutePath));

, "" , .

0

Source: https://habr.com/ru/post/1772985/


All Articles