Server.MapPath option use strategy

Before you start creating your project with ASPRunnerPro you have to decide if you are going to publish your site to your local computer or to the remote web server. In this connection it's important to know location of your database file.


1. Running ASP Pages on Local Computer.

ASP Runner's default settings provide that application you are creating does not work directly with original database. Wizard creates temporary copy and places it in the DB folder that will be created in the Output directory. Generated ASP pages will be stored there as well.
If by any reason you want to work directly with the original database or place temporary copy to another folder, you should use the Server.MapPath option on Access database connection screen.

By default, this option is on and default value of the Path field is db. To place temporary file to another directory you need to type relative path pointing to the temporary copy of the database in the Path field. To avoid possible mistakes you should be careful while entering new path. And if you just set this option to off, all changes will be made in the original database.

And if you just set this option to off, all changes will be made in the original database.

2. Running ASP Pages on the Remote Web Server.

Now, let's look at the case when you want to publish your site to the remote web server. In this case, location of your database file becomes the most actual issue since quite often hosting providers have designated folder for databases.

If you face such problem, you should use Server.MapPath option. In the Path field you should enter relative path that will be used in database connection string. In this case ASPRunner creates a copy of database in the Output folder. When you test ASP pages locally, they will work just with this copy of database.

Next, you need to upload generated files and the database file to the server considering the path that you've entered in the Path field.

If your hosting supports FTP connection, the most convenient way is to use FTP client built-in to the ASPRunner Pro, with it you can chose different directories for generated files and database file. Connection string will be updated to match new database folder automatically.

Thus, we will get three copies of database: original, temporary and the copy stored on the web server.

3. Additional Information.

It is quite possible that you will need to make changes in the database after you have already published your site and at the same time save changes made online.

In this case you need to take the following steps:

  • Using FTP, download database to your local computer
  • Replace original database with it
  • Make necessary changes
  • Generate new files with ASPRunner (rebuild the project)
  • Upload data back to the web server

It's worth mentioning that in some cases the Server.MapPath function works incorrectly. The reason is the following: sometimes it is necessary to export database file one level up from ASP files, but some servers do not allow using parent paths (for example, ..\db). In this case you may receive the following error message:

Active Server Pages error 'ASP 0131'
Disallowed Parent Path.

This problem can be resolved by changing dbconnection.asp file found in the Include folder of the Output directory.

Let's look at the real example. Let's assume you need to store generated ASP pages in Wwwroot directory and the database file in DB directory.

Create ASP file named test.asp. To do it, open any text editor and copy the following text there:

Save this file in that directory on the server where you plan to place ASP files (wwwroot in our example). In your Internet browser enter http://localhost/test.asp. The line will be displayed showing absolute path you need. Great! So, your directory is placed at c:/inetpub.

Open dbconnection.asp in the text editor and make the following changes in the strConnection string:

4. Troubleshooting.

Finally, here are examples of the most frequent errors that occur while using the Server.MapPath:

  • Server.MapPath(), ASP 0174 (0x80004005)

  • An invalid '/' or '\' was found in the Path parameter for the MapPath method.
    /ASPRunnerPro/include/dbconnection.asp, line 3

This commonly occurs when you use double instead ordinary slash (for example: //inetpub//db)

  • Server.MapPath(), ASP 0173 (0x80004005)

  • An invalid character was specified in the Path parameter for the MapPath method.
    /ASPRunnerPro/include/dbconnection.asp, line 3

Probably you use invalid characters in Path field such as: :,*,?,!,<,>,|

  • Server.MapPath(), ASP 0176 (0x80004005)

  • The Path parameter for the MapPath method did not correspond to a known path.
    /ASPRunnerPro/include/dbconnection.asp, line 3

The above error can occur when you point to non-existent path. It may be necessary to remove the '../' in Path field.

Back to top