URL retrieval is simple. ASP. NET is common:
[1]Obtain the complete URL
(Protocol name + domain name + virtual directory name + file name + parameter)
String url = request. url. tostring ();
[2]Obtain the virtual directory name + Page name + parameter:
String url = request. rawurl;
(Or string
Url = request. url. pathandquery ;)
[3]Obtain
Virtual directory name + Page name:
String url = httpcontext. Current. Request. url. absolutepath;
(Or
String url = httpcontext. Current. Request. Path ;)
[4]Retrieve Domain Name:
String
Url = httpcontext. Current. Request. url. Host;
[5]Obtain parameters:
String url =
Httpcontext. Current. Request. url. query;
[6]Obtain Port:
Request. url. Port
2. Obtain the current controller and action
Routedata. route. getroutedata (this. httpcontext). Values ["controller"]
Routedata. route. getroutedata (this. httpcontext). Values ["action"]
Or
Routedata. Values ["controller"]
Routedata. Values ["action"]
If you can use
Viewcontext. routedata. route. getroutedata (this. Context). Values ["controller"]
Viewcontext. routedata. route. getroutedata (this. Context). Values ["action"]
Or
Viewcontext. routedata. Values ["controller"]
Viewcontext. routedata. Values ["action"]