Hi All
I have a 'small' problem. :sick:
Is there any way to use Server.mapPath in the web.config when specifying the connection string for my database?
I have been able to use it in my webforms but want to keep it stored in one place, namely the web.config file.
Unfortunately, I am getting errors when I try to use "&" when constructing my connectionstring using Server.mappath(".")
Has anyone done this before?
I also noticed that Server.mappath is not recognized when I tried to use it in a vb class file, although I am able to use it in the code-behind file of a webform. Any ideas?
ThanksI dont think you can use server.Mappath in the Config file. You will have to hard-code the path of your Access(?) DB there.
To use it in a .vb file you need to write the full namespace, ie.
httpcontext.Current.Server.MapPath()
..or import the namespace.
The web.config file is there to be configured when u set up an application. Thats why it can be modified in a normal text editor. You'll need to specify the full (or relative) path to the access database.
Don't store the phrase Server.Mappath in your web.config. Just store the latter part of the string, which should be concatenated with Server.Mappath in your application.
Tuesday, March 13, 2012
Server.MapPath and web.config
Labels:
alli,
asp,
config,
connection,
mall,
mappath,
net,
server,
servermappath,
sick,
specifying,
string,
web,
webconfig
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment