Web.Config and appSettings tag

Ask a Question related to ASP.NET Web Services, Design and Development.

  1. #1

    Default Web.Config and appSettings tag

    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+abzzXG bUIOV1DVRY3RUt3Nozg8STBo6pFscRROzshjtheWwsmkQcEv4B Usnj2Fxpv41hBLW45tGIyAKraHT19PCbbglkBu7jRZgRcj32I/FnoBotRrNcOdKpXuQep17U7qVw44=" />
    <add key="SqlConnection"
    value="gGVy3Wyj1YSs7sIHEEqsR0NdShs27Wf+VhRHPigbR44 2cuoTAstzHWTRzeaNLwnfxISqske9+rQiKGqJupJkLYemi9XvM wsXLVByokEZixrr/PUlsmDMJIGhPc9dZFzIYsn9PUPfKD63ieGFKv76QKiMIbIbOQZ yPMoaMWovIWJNmYwfDWZhOvO2pVvK9lxxiaC1Xe58wd54EYc/4JNwQxv2ugDiY167tJQL88ADBc+4rOwyYN093CaITBKtF7H3Ng aQZWeIE9rSr+/5pbn1I+54BirRo4bproDoi0/vxrFV1oFXJuDKJLxc8PtM6JeCqjpBPFFskXsFoFXOLI5YGNyCN QbmOFqllWTFW8p9U+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
    Stevet96 Guest

  2. Similar Questions and Discussions

    1. How secure are appsettings in web.config?
      Just wondering how safe it is to include sensitive information such as a database connection string in web.config.
    2. How: Ampersand in AppSettings value??
      I am wondering how i can put an ampersand character into the value attribute of a key in the appSettings section of my web.config file. If i try to...
    3. Intermittent problem reading appSettings in Web.Config
      Are you positive this is a web config issue? You yourself say you don't know what is being returned. When you resave web.config, this restarts...
    4. appSettings problem!
      Hello! I have one problem with the appSettings on win2k srv machine with framework 1.1. Following line not work anymore (it worked fine with...
    5. ConfigurationSettings.AppSettings Error
      Hello Chris, When you are experiencing this problem? What are you including in the AppSettings Config file. Are you using long string? What...
  3. #2

    Default RE: Web.Config and appSettings tag

    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

    "Stevet96" wrote:
    > 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+abzzXG bUIOV1DVRY3RUt3Nozg8STBo6pFscRROzshjtheWwsmkQcEv4B Usnj2Fxpv41hBLW45tGIyAKraHT19PCbbglkBu7jRZgRcj32I/FnoBotRrNcOdKpXuQep17U7qVw44=" />
    > <add key="SqlConnection"
    > value="gGVy3Wyj1YSs7sIHEEqsR0NdShs27Wf+VhRHPigbR44 2cuoTAstzHWTRzeaNLwnfxISqske9+rQiKGqJupJkLYemi9XvM wsXLVByokEZixrr/PUlsmDMJIGhPc9dZFzIYsn9PUPfKD63ieGFKv76QKiMIbIbOQZ yPMoaMWovIWJNmYwfDWZhOvO2pVvK9lxxiaC1Xe58wd54EYc/4JNwQxv2ugDiY167tJQL88ADBc+4rOwyYN093CaITBKtF7H3Ng aQZWeIE9rSr+/5pbn1I+54BirRo4bproDoi0/vxrFV1oFXJuDKJLxc8PtM6JeCqjpBPFFskXsFoFXOLI5YGNyCN QbmOFqllWTFW8p9U+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
    Stevet96 Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139