How do I get the full url of the page I am on in C#
Here is a list I normally refer to for this type of information:
Request.ApplicationPath : /virtual_dirRequest.CurrentExecutionFilePath : /virtual_dir/webapp/page.aspxRequest.FilePath : /virtual_dir/webapp/page.aspxRequest.Path : /virtual_dir/webapp/page.aspxRequest.PhysicalApplicationPath : d:\Inetpub\wwwroot\virtual_dir\Request.QueryString : /virtual_dir/webapp/page.aspx?q=qvalueRequest.Url.AbsolutePath : /virtual_dir/webapp/page.aspxRequest.Url.AbsoluteUri : http://localhost:2000/virtual_dir/webapp/page.aspx?q=qvalueRequest.Url.Host : localhostRequest.Url.Authority : localhost:80Request.Url.LocalPath : /virtual_dir/webapp/page.aspxRequest.Url.PathAndQuery : /virtual_dir/webapp/page.aspx?q=qvalueRequest.Url.Port : 80Request.Url.Query : ?q=qvalueRequest.Url.Scheme : httpRequest.Url.Segments : / virtual_dir/ webapp/ page.aspx
Hopefully you will find this useful!
I usually use Request.Url.ToString()
to get the full url (including querystring), no concatenation required.
Request.Url.AbsoluteUri
This property does everything you need, all in one succinct call.