get the base url in the code behind?

G

Guest

Hi;

I need to get the base url (what pages in my app are added to to make the
complete url). To do this when I have a request object it's a piece of cake -
I use http://www.davidthielen.info/programming/2006/10/base_url_in_an_.html

But I have an event handler for my HttpApplication. In that event handler I
create html pages. If those pages have images, I need to have links to the
images that I will serve up.

It seems to me this may be impossible. Because I may hit the site using
http://server while someone else uses http:///www.domain.com, etc. Is there a
way to do this?

Or am I right that it makes no sense because of aliases for the same machine?

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm
 
S

Steven Cheng[MSFT]

Thanks for Keith's input.

Hi Dave,

In addition to the site root specific path (start with "/"), you can also
use the Page.ResolveUrl("~/...") to get application root specific path.
Actually, for client browser, as long as it has requested the first page on
a website, it will record the base url (servername) and sequential
requests through root specific path ( start with "/...") can be correctly
resolved then.

Anyway, I think you're right that we can not get all the possible public
DNS name of our server(that will be used by different internet clients) in
the application itself.

Please feel free to post here if you have any further questions.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.
 

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

Members online

No members online now.

Forum statistics

Threads
473,989
Messages
2,570,207
Members
46,782
Latest member
ThomasGex

Latest Threads

Top