.net - How to access the HttpServerUtility.MapPath method in a Thread or Timer? -


i use system.timers.timer in asp.net application , need use httpserverutility.mappath method seems available via httpcontext.current.server.mappath. problem httpcontext.current null when timer.elapsed event fires.

is there way reference httpserverutility object ? inject in class' constructor. safe ? how can sure won't garbage collected @ end of current request?

thanks!

it's possible use hostingenvironment.mappath() instead of httpcontext.current.server.mappath()

i haven't tried yet in thread or timer event though.


some (non viable) solutions considered;

  • the method care on httpserverutility mappath. alternative use appdomain.currentdomain.basedirectory , build paths this. but fail if app uses virtual directories (mine does).

  • another approach: add paths need the global class. resolve these paths in application_start.


Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -