Hi,
I have a mailhandler class in my MVC webapplication and needs to get a physical path to the mailTemplate file (a couple of folders down the root). How do I do this? Do I have to send in some kind of httpContext? My mailHandler is a singelton so there is no constructor for parameters :
public static EmailHandler Instance
{
get {
if (EmailHandler._emailHandler == null)
EmailHandler._emailHandler = new EmailHandler();
return EmailHandler._emailHandler; }
set { EmailHandler._emailHandler = value; }
}
Any idea?
Personally, I would just tell it the base-path to use; then the same code can work in a number of environments, not just web. If you are web-bound, HttpContext.Current may help. If you want to pass it in, I would instead pass in the abstracted HttpContextBase, ala MVC.
But passing in a string of the base-path is a lot easier 🙂