Reputation: 29
I put the server.MapPath code in ASP.NET VB code behind.
On my laptop i compile and build. However when i upload my web application to the actual server. I received error where the link is still referencing the laptop link.
How can i solve this issue?
My code is
Server.MapPath("./scorecardsheet/db.xls")
Actual server link is c:\Inetpub\vhosts\xxx.com\httpdocs\xxx\scorecardsheet\db.xls
but when i run the page on the server it shows the link of my development platform as c:\user\jerry\visual studio 2010\projects\xxx\xxx\scorecardsheet\db.xls
Upvotes: 2
Views: 751
Reputation: 25137
You probably want Server.MapPath("~/scorecardsheet/db.xls")
instead, yes? Note the special ASP.NET tilde (~
) symbol instead of the current directory symbol (.
) This way it will calculate the relative path based on the location of the web site root wherever it is on the system.
Upvotes: 1