What is the difference between Server.MapPath and HostingEnvironment.MapPath?

Server.MapPath() eventually calls HostingEnvironment.MapPath(), but it creates a VirtualPath object with specific options:

The VirtualPath object passed to HostingEnvironment.MapPath() is constructed like this:

VirtualPath.Create(path, VirtualPathOptions.AllowAllPath|VirtualPathOptions.AllowNull);

Edit: in reality, the only difference is that you are allowed to pass null to Server.MapPath(), but not to HostingEnvironment.MapPath()

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)