Web.Config and appSettings tag

S

Stevet96

I am storing a database connection string in a key/value pair in the
appSettings tag of the web.config file as follows:

<appSettings>
<add key="DB2Connection"
value="NU2xZIOswP0Ar7fyDzqFCalmIx1tGDvVt92I+abzzXGbUIOV1DVRY3RUt3Nozg8STBo6pFscRROzshjtheWwsmkQcEv4BUsnj2Fxpv41hBLW45tGIyAKraHT19PCbbglkBu7jRZgRcj32I/FnoBotRrNcOdKpXuQep17U7qVw44=" />
<add key="SqlConnection"
value="gGVy3Wyj1YSs7sIHEEqsR0NdShs27Wf+VhRHPigbR442cuoTAstzHWTRzeaNLwnfxISqske9+rQiKGqJupJkLYemi9XvMwsXLVByokEZixrr/PUlsmDMJIGhPc9dZFzIYsn9PUPfKD63ieGFKv76QKiMIbIbOQZyPMoaMWovIWJNmYwfDWZhOvO2pVvK9lxxiaC1Xe58wd54EYc/4JNwQxv2ugDiY167tJQL88ADBc+4rOwyYN093CaITBKtF7H3NgaQZWeIE9rSr+/5pbn1I+54BirRo4bproDoi0/vxrFV1oFXJuDKJLxc8PtM6JeCqjpBPFFskXsFoFXOLI5YGNyCNQbmOFqllWTFW8p9U+HSGNKus8qVjLj5oDxvyC3x/HyDKP3K3sR7MgJek+ftTw==" />
</appSettings>

The values are encrypted using the encryption available in .NET. When I
only have the first key/value pair in appSettings, the ASP.NET web service
works fine including the decrypting of the value and the subsequent DB
connection. When I added the second key/value pair, I started to get the
following error message "Format of the initialization string does not conform
to specification starting at index 0." I did a search and the first thing
that I made sure was that I was correctly decrypting the string. However
when I went to debug the webservice, I was not able hit a break point even
at the beginning of the web service function. The web service is not able to
load the web.config file to use. I then tried to store the connection
string in plain text (unencrypted) in the value and the webservice worked
including connecting to the database. It appears that there is some issue
with the encrypted string. I tried to encrypt the connection string using a
different encryption key to generate a different value, but that also
generated the same error.

Is there is limit to the length a value can be in the appSettings tag? Is
there some sort of format issue that I dont see? Again if I take the second
key/value out the web service runs just fine. I used the same encryption
technique for both key/value pairs.

Thanks for your help,
Steve
 
S

Stevet96

I just love it when you answer your own post. It turns out that an object
that was using the connection string was somehow being initialized before I
even got into my webservice function. Not sure how that happens since it
shouldn't be loaded until I call new on it. Anyway, I stopped the object
from reading in the encrypted text before it was decrypted.

Thanks,
Steve
 

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

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top