Tuesday, March 13, 2012

Server.MapPath

Hi all,

Is it possible to put Server.MapPath in the web.config file? If so, how?

Cheers,
DavidI know of no way to do this (but if someone else knows - - ) - - - The problem is that neither the '&' or the '+' characters are allowed in a web.config file in the standard way you'd use it.
I dont think you can either.. whywould you want to anyway ?
I would think he's probably wanting to save the connection string for an MDB file there, just like you would for a SQL server connection string
Try this instead.

<appSettings>
<add key="datesdb"
value="Provider=Microsoft.Jet.OLEDB.4.0; data source=c:/My_dbs/dates2.mdb" />
</appSettings
***Remember to keep your databases out of the wwwroot folder for security reasons.
I forgot to show how to reference it:

Dim strConn As String = ConfigurationSettings.AppSettings("datesdb")
Ahhh yes, I've been workign with SQL Server so long i forgot about access files :)

0 comments:

Post a Comment