4

I'm attempting to use appcmd to set an appSetting in web.config, the value for the appSetting contains a + symbol. When I run appcmd, the appSetting is created, but the + is converted to a space.

the appcmd i'm running:

"C:\system32\inetsrv\appcmd.exe" set config "Default Web Site" /section:appSettings /+"[key='Test',value='++ ++']"

the appSetting that is created:

<add key="Test" value="     " />

I've tried using %2b instead of + in the appcmd, this didn't work (it was converted to just the 'b' in the appSetting.

Does anybody have any idea how i can get a + symbol included in the appSetting when using appcmd?

1 Answers1

3

Have you tried using the unicode value of + which is %u002b?

"C:\system32\inetsrv\appcmd.exe" set config "Default Web Site" /section:appSettings 
/+"[key='Test',value='%%u002b']"

You need to add an additional % sign in order to escape the % in the unicode value.

That should result in the Test key having a value of +.

See:

mezoid
  • 28,090
  • 37
  • 107
  • 148