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.