Building a complete HTTP URL

  • Thread starter Thread starter Rob Nicholson
  • Start date Start date
You can do:

string url = Request.ApplicationPath + "/SomeDirRelativeToYourRoot/File.aspx";

Note that if your app is at the root of the website, then Request.ApplicationPath
returns "/", so the URL will (incorrectly) start with "//", so you should
check for that.

Do you need the absolute path in what you're rendering? Usually the client,
if given a relative URL, will determine the full path based upon the context.

-Brock
DevelopMentor
http://staff.develop.com/ballen
 
Back
Top