Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get Address bar in C#?

Status
Not open for further replies.

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
 
You will need to get the server variables:

//get protocol
string sProtocol = "
if(Request.ServerVariables["HTTPS"]) = "ON")
{
sProtocol ="}
//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.
 
Thanks Affleck, little bit of Regex to strip out the fluff and it works like a charm!
 
Hi,

a shorter way is:

string addressBar = Request.Url;

Cheers
 
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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top