




Вы можете использовать string.Split():
var url = "localhost:50981/Admin/AddCustomer.aspx";
var result = url.Split('/').Last().Split('.')[0];
Чтобы получить текущий Url путь в Асп.Нет:
var url = HttpContext.Current.Request.Url.AbsolutePath;
Примечание:
Если вам интересно, как получить разные части URL-адреса, посмотрите ответ это:
var scheme = Request.Url.Scheme; // will get http, https, etc. var host = Request.Url.Host; // will get www.mywebsite.com var port = Request.Url.Port; // will get the port var path = Request.Url.AbsolutePath; // should get the /pages/page1.aspx part, can't remember if it only get pages/page1.aspx
Вы можете использовать AbsolutePath в своей onLoad функции страницы.
//AddCustomer or Customer
string yourPath = HttpContext.Current.Request.Url.AbsolutePath.Split('/').Last().Split('.')[0];