I want current url path along with its query string.
I have tried below but not getting desired output.
var pathname = window.location.pathname; // Returns path only
var url = window.location.href;
Suppose my url is http://localhost:1111/Contact/Index?text=aa.
Note : query string is optional here if there is no query string then it should provide pathname only.
I want /Contact/Index?text=aa, TIA.