DataDirectory value substitution in web.config in ASP.NET 2.0

G

Guest

Hi,

I have a major issue with the way |DataDirectory| gets substituted when used
in a connection string in web.config. In a simple scenario when a precompiled
web site xcopied to a target web server (e.g. to a staging or production web
server). It seems |DataDirectory| still gets substituted with the path of
App_Data directory on the source web server and not the target server’s
App_Data directory.

For example this is what I have in my web.config file:
connectionString="Data Source=.\SQLExpress;Integrated Security=True;User
Instance=True;AttachDBFilename=|DataDirectory|aspnetdb.mdf"

when I compile the application on the development box and then copy it to
the staging server, when I run the application and try to access the
database, it generates an error message showing the path of aspnetdb.mdf on
the development box which is obviously different on the staging server. In
other words it tries to resolve the |DataDirectory| with the value from the
source server not the target server.

Thanks,
PJ
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top