Reputation: 13
When i start to attach the same file to AdRotator object, it didn't work :
AdRotator1.AdvertisementFile = Server.MapPath("~/Data/Ads.xml");
Then i used, and it worked:
AdRotator1.AdvertisementFile = "~/Data/Ads.xml";
Can anyone tell me when to use Server.MapPath?
Upvotes: 1
Views: 397
Reputation:
From Microsoft: The MapPath method maps the specified relative or virtual path to the corresponding physical directory on the server.
So when you call Server.MapPath("~/Data/Ads.xml")
it returns the complete path, including the directory on the server. But in your case, you probably just need the relative path, so you don´t need to call Server.MapPath
.
Upvotes: 1
Reputation: 646
The MapPath method maps the specified relative or virtual path to the corresponding physical directory on the server
Upvotes: 1