Building a complete HTTP URL

B

Brock Allen

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top