I would like to remove the last segment of Request.Url
, so for instance...
http://www.example.com/admin/users.aspx/deleteUser
Well the trivial solution would be to iterate char by char from the end of the string towards its beginning and search for the first '/' to come (I guess that also came into your mind).
Try this:
string url = "http://www.example.com/admin/users.aspx/deleteUser";
for (int i = url.Length - 1; i >= 0; i--) {
if (url[i] == '/') return url.Substring(0, i - 1);
}