Jun 29, 2006 #1 lynque IS-IT--Management Sep 30, 2004 124 CA Is it possible to grab the contents of a browsers address bar in C#? I know you can do it with JavaScript but I'm trying to get away from using client side scripts. TIA
Is it possible to grab the contents of a browsers address bar in C#? I know you can do it with JavaScript but I'm trying to get away from using client side scripts. TIA
Jun 29, 2006 #2 Affleck Technical User Jun 19, 2001 26 GB You will need to get the server variables: //get protocol string sProtocol = "http://"; if(Request.ServerVariables["HTTPS"]) = "ON") { sProtocol ="https://";} //get domain string sDomain = Request.ServerVariables["SERVER_NAME"]; //path string sQuerystring = Request.Querystring; //then put them all together string address = sProtocol+ sDomain + sQuerystring something like that anyway you get the idea. Affleck there are 10 types of people in this world those who understand binary, and those who don't. Upvote 0 Downvote
You will need to get the server variables: //get protocol string sProtocol = "http://"; if(Request.ServerVariables["HTTPS"]) = "ON") { sProtocol ="https://";} //get domain string sDomain = Request.ServerVariables["SERVER_NAME"]; //path string sQuerystring = Request.Querystring; //then put them all together string address = sProtocol+ sDomain + sQuerystring something like that anyway you get the idea. Affleck there are 10 types of people in this world those who understand binary, and those who don't.
Jun 29, 2006 Thread starter #3 lynque IS-IT--Management Sep 30, 2004 124 CA Thanks Affleck, little bit of Regex to strip out the fluff and it works like a charm! Upvote 0 Downvote
Jun 30, 2006 #4 mit99mh Programmer Sep 24, 2002 246 GB Hi, a shorter way is: string addressBar = Request.Url; Cheers Upvote 0 Downvote
Jul 4, 2006 Thread starter #5 lynque IS-IT--Management Sep 30, 2004 124 CA Thanks mit99mh but the URL is rewritten, hence needing the contents of the address bar itself and not simply the URL. Probably should have mentioned that. Upvote 0 Downvote
Thanks mit99mh but the URL is rewritten, hence needing the contents of the address bar itself and not simply the URL. Probably should have mentioned that.