Gets the current url
- 2020-05-05 11:05:52
- OfStack
Such as: http: / / localhost newurl/WebForm1 aspx
1. Method document.URL(note case)
Result: http: / / localhost newurl/WebForm1 aspx
2.HttpContext.Current.Request.Url.ToString(),
Results: http: / / localhost newurl/WebForm1 aspx
3.HttpContext.Current.Request.Url.PathAndQuery;
Results: / newurl WebForm1 aspx
Note:
If the current URL is
http://localhost/search.aspx?user=tinyfool&tag=%BC%BC%CA%F5
Through HttpContext. Current. Request. Url. ToString () get
http://localhost/search.aspx?user=tinyfool&tag=¼¼Êõ
That's obviously not right. What do we do? Use HttpContext. Current. Request. Url. PathAndQuery ok, this is correct. :)
4.Javascript takes url value
A small example I just wrote. It's pretty much used in practice.
1. Method document.URL(note case)
Result: http: / / localhost newurl/WebForm1 aspx
2.HttpContext.Current.Request.Url.ToString(),
Results: http: / / localhost newurl/WebForm1 aspx
3.HttpContext.Current.Request.Url.PathAndQuery;
Results: / newurl WebForm1 aspx
Note:
If the current URL is
http://localhost/search.aspx?user=tinyfool&tag=%BC%BC%CA%F5
Through HttpContext. Current. Request. Url. ToString () get
http://localhost/search.aspx?user=tinyfool&tag=¼¼Êõ
That's obviously not right. What do we do? Use HttpContext. Current. Request. Url. PathAndQuery ok, this is correct. :)
4.Javascript takes url value
A small example I just wrote. It's pretty much used in practice.
[Ctrl+A full selection note: if external Js needs to be introduced, it needs to be refreshed to execute]