Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / March 2008

Tip: Looking for answers? Try searching our database.

How do I get DNS name and port in code

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Michael Burgess - 12 Mar 2008 18:59 GMT
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.
Peter Bromberg [C# MVP] - 12 Mar 2008 21:01 GMT
Well, first off, your code should be designed to not be sending the email if
the properties are null.  Have you tried using Httpcontext.Current.Request?
If that doesn't work, you could maybe assign the items to static fields in
Global, or just approach the problem from a different angle with some good
lateral thinking.
-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short Urls & more: http://ittyurl.net

> Hi there,
>
[quoted text clipped - 18 lines]
> Thanks in advance,
> Michael.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.