23

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
  • 56,151
  • 24
  • 92
  • 147
Viacheslav Smityukh
  • 5,132
  • 2
  • 20
  • 36

2 Answers2

45

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

NakedBrunch
  • 45,899
  • 13
  • 69
  • 97
4

you can also try:

HttpContext.Current.Request.PhysicalApplicationPath
safi
  • 3,040
  • 7
  • 22
  • 36