How do I get DNS name and port in code

  • Thread starter Thread starter Michael Burgess
  • Start date Start date
M

Michael Burgess

Hi there,

I have some code thatr does the following:

Managers.AppUrl = String.Format("http://{0}:{1}{2}",Request.Url.Host,
Request.Url.Port, Request.ApplicationPath);

To assign the URL of an ASP.NET site to a property - this is called
from the startup code of the default page.

This works fine, although I now have a scenario where I need to get at
this value in one of my utility classes. This utility class runs on a
timer thread that's kicked off during Application_Start in
Global.asax. It's hitting this code before the default page has loaded
and the value isn't initialized, so the URL I subsequently mail to
users to click is empty.

I can't get at the 'Request' object in Global.asax, so how can I build
up a dynamic URL to mail to users outside of a HTTPRequest scenario?

Thanks in advance,
Michael.
 

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

Back
Top