2

Can someone please explain the difference between Server.MapPath and Request.MapPath and usage scenarios for the two ?

Nick
  • 117
  • 3
  • 11

1 Answers1

1

ASP.NET has provided at least three different public MapPath methods since version 2.0:

Internally, HttpServerUtility.MapPath calls HttpRequest.MapPath.

HostingEnvironment.MapPath is a static method, throws an ArgumentNullException if the argument is null or empty, and throws an ArgumentException if the argument is a relative path.

HttpRequest.MapPath is not a static method and does not throw the exceptions mentioned above.

Ryan Prechel
  • 6,592
  • 5
  • 23
  • 21