25

I have my owned siteMapProvider, I need phisical file path to initialize it but I can't use HttpContext to do that, because IIS 7 will thrown exception:

fileName = HttpContext.Current.Server.MapPath(fileName);

How can I do MapPath without HttpContext?

tereško
  • 58,060
  • 25
  • 98
  • 150
Viacheslav Smityukh
  • 5,652
  • 4
  • 24
  • 42

2 Answers2

46

Take a look at the following: HttpRuntime.AppDomainAppPath (from MSDN)

NakedBrunch
  • 48,713
  • 13
  • 73
  • 98
5

you can also try:

HttpContext.Current.Request.PhysicalApplicationPath
safi
  • 3,636
  • 8
  • 24
  • 37