I’ve got to make some changes to an app that has many hard-coded paths. These paths are based on the assumption that the application path is null. But when I run locally in visual studio the app path is something else. So on the production server the name might be “http://example.com/default.aspx”, while locally it is something like “http://localhost:1234/myapp/default.aspx”.
Is there any way to set the application path in visual studio, so I can set it to null?
And yes, yes, I know that the “right answer” is to eliminate the hard-coded paths. Long term, I’d love to do that. But that would be a lot of work for a modest change, and then I’d have to test everything in sight to make sure I didn’t screw something up.
In the webapp project properties, under Web, in the Servers section you can select the server and the app path on that server. If you use Visual Studio Development Server, the default path is “/”.
Also, when you publish your app, you can select profiles with their relative target location (right-click project and Publish).
Lastly, you can use the ~ (tilde) in front of your relative hardcoded paths to signify that they belong to the root webapp folder.