ASP.NET - Get website's URL without HttpContext.Current (running in background thread) -


Bit of a long shot, but there is a way in ASP.NET, when the URL of the website gets dynamically There is no HttpContext.Current available

There is no HttpContext because the code is running in the background thread * (but under ASP.NET AppDomain). I have a background process that sends emails every evening, and the web address is required to be included, but I do not want to do a hard code due to deployment and testing (this then changes to the live site). . / P>

* Please do not advise a Windows service, but I am aware of this, but hosting restrictions prevents me from doing this.

Your app should create and start threads. Thread has been created at this point, the HTTP Contex. The current should be available, store the relevant part of the web address that is important and pass it to the constructor of your object that wraps the threading functionality, or if you do not have a custom object, store it in that location. Where the thread can access it If you use the latter approach then you need to enter a critical section with lock () {} Received.


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -