In a common ASP.NET Web Forms page, I specify the location of a backup file as follows:
string backupFilePath = "../data/backups";
ICronjobTask[] tasks = new ICronjobTask[]
{
new FileBackupCronjobTask(backupFilePath)
};
The ICronjobTask
is executed later on. When c开发者_如何学运维alling the published page on my web server, an error message tells me that parts of the path "C:\Windows\SysWOW64\inetsrv\data\backups\file.txt
could not be found.
Why does ASP.NET publish my local directory structure? How do I turn this off?
You're displaying the raw exception error message, is my guess. Whenever you do that, you risk giving away information that you don't want to be made public. Instead of doing that, you should interpret the exception and give general information to the user.
The solution was to use the Server.MapPath(string path)
method that returns the physical path corresponding to the specified logical one.
精彩评论