![]() |
|
|
|||||||
![]() |
ASP Net - Multi-lined appsettings value in web config |
|
|
Thread Tools | Search this Thread |
|
|
#1 |
|
Hello Microsoft.
In a web config file, I intend to set a value in the appsettings as such: <add key="ApplicationA" value="[Application Name]:MyApp1|| [PropertyA] ... " When I compile, it replaces the CRLF with 
 and pushes the whole text for the item onto a single line. I intend on having a moderately large value in here. Before anyone asks why I need this it is because, instead of having multiple keys that essentially relate to the same object, I intend on creating one single key with multiple internal values in a preset structure that I can use as a standard format. I can include stuff like connection string information and the such. I have tried the standard method and it sucks. When you look at a web.config file that has information on a complex application it gets really difficult to read the values, knowing what goes with what. This way I can group all the information together in one string, which makes sense logically. I want to know either how to stop the designer from reordering my value-text when I compile, or how do I concatenate values in the web config, like I would in a section of code, thus: mytext = oldtext & ',' & appendedtext. Eg. can I use <add key="ApplicationA" value="[Application Name]:MyApp1||" + "[PropertyA] " ... " Thanks in advance Nick Large |
|
|
|
|
#2 |
|
Posts: n/a
|
"Nick Large" <> wrote in message news:... Hello Microsoft. In a web config file, I intend to set a value in the appsettings as such: <add key="ApplicationA" value="[Application Name]:MyApp1|| [PropertyA] ... " When I compile, it replaces the CRLF with 
 and pushes the whole text for the item onto a single line. I intend on having a moderately large value in here. Before anyone asks why I need this it is because, instead of having multiple keys that essentially relate to the same object, I intend on creating one single key with multiple internal values in a preset structure that I can use as a standard format. I can include stuff like connection string information and the such. I have tried the standard method and it sucks. When you look at a web.config file that has information on a complex application it gets really difficult to read the values, knowing what goes with what. This way I can group all the information together in one string, which makes sense logically. I want to know either how to stop the designer from reordering my value-text when I compile, or how do I concatenate values in the web config, like I would in a section of code, thus: mytext = oldtext & ',' & appendedtext. Eg. can I use <add key="ApplicationA" value="[Application Name]:MyApp1||" + "[PropertyA] " ... " Thanks in advance Nick, consider writing a custom configuration section handler, and then placing your complex initialization stuff into its own section, in plain old XML inside the web.config file. A little Googling, or a snoop around in the MSDN library, should turn up the documentation on how to do this. It's not too tough, and once it's done your data in web.config can be as complex as you like. Tom Dacon Dacon Software Consulting Tom Dacon |
|
|
|
#3 |
|
Posts: n/a
|
Hi Nick,
>Hello Microsoft. >In a web config file, I intend to set a value in the appsettings as such: ><add key="ApplicationA" > value="[Application Name]:MyApp1|| > [PropertyA] > ... " >When I compile, it replaces the CRLF with 
 and pushes the whole text for the item onto a single line. Based on my test, normal ASP.NET Application will not change CRLF in its web.config with 
 after compile. My guess is you're using Web development project, right? If so please refer to my previous case to learn how to use custom task to replace a string in web.config: http://www.microsoft.com/communities...aspx?dg=micros oft.public.dotnet.framework.aspnet&tid=dd83befb-d870-40dc-bcb4-8a49fc5f85d4& cat=&lang=&cr=&sloc=&p=1 Your probably need to write a custom action to do this. Please use Reflector to view the source code of: MSBuild.ExtensionPack.FileSystem.File and write your custom action class. Please let me know whether my understanding is correct and whether above approach can solve this issue. Regards, Allen Chen Microsoft Online Support Delighting our customers is our #1 priority. We welcome your comments and suggestions about how we can improve the support we provide to you. Please feel free to let my manager know what you think of the level of service provided. You can send feedback directly to my manager at: . ================================================== Get notification to my posts through email? Please refer to http://msdn.microsoft.com/en-us/subs...#notifications. Note: MSDN Managed Newsgroup support offering is for non-urgent issues where an initial response from the community or a Microsoft Support Engineer within 2 business day is acceptable. Please note that each follow up response may take approximately 2 business days as the support professional working with you may need further investigation to reach the most efficient resolution. The offering is not appropriate for situations that require urgent, real-time or phone-based interactions. Issues of this nature are best handled working with a dedicated Microsoft Support Engineer by contacting Microsoft Customer Support Services (CSS) at http://msdn.microsoft.com/en-us/subs.../aa948874.aspx ================================================== This posting is provided "AS IS" with no warranties, and confers no rights. Allen Chen [MSFT] |
|
|
|
#4 |
|
Posts: n/a
|
forget the line feeds and use just use a delimiter
<add key="ApplicationA" value="[Application Name]:MyApp1|[PropertyA] "Nick Large" <> wrote in message news:... Hello Microsoft. In a web config file, I intend to set a value in the appsettings as such: <add key="ApplicationA" value="[Application Name]:MyApp1|| [PropertyA] ... " When I compile, it replaces the CRLF with 
 and pushes the whole text for the item onto a single line. I intend on having a moderately large value in here. Before anyone asks why I need this it is because, instead of having multiple keys that essentially relate to the same object, I intend on creating one single key with multiple internal values in a preset structure that I can use as a standard format. I can include stuff like connection string information and the such. I have tried the standard method and it sucks. When you look at a web.config file that has information on a complex application it gets really difficult to read the values, knowing what goes with what. This way I can group all the information together in one string, which makes sense logically. I want to know either how to stop the designer from reordering my value-text when I compile, or how do I concatenate values in the web config, like I would in a section of code, thus: mytext = oldtext & ',' & appendedtext. Eg. can I use <add key="ApplicationA" value="[Application Name]:MyApp1||" + "[PropertyA] " ... " Thanks in advance germ |
|
|
|
#5 |
|
Posts: n/a
|
On Nov 5, 9:16*pm, "Nick Large" <msnew...@nospam.nospam> wrote:
> Hello Microsoft. > > In a web config file, I intend to set a value in the appsettings as such: > > <add key="ApplicationA" > * *value="[Application Name]:MyApp1|| > * * * * * [PropertyA] > * * * * * * ... " > > When I compile, it replaces the CRLF with 
 and pushes the whole text for the item onto a single line. *I intend on having a moderately large value in here. > For me it works. in the web.config file <appSettings> <add key="ApplicationA" value="[Application Name]:MyApp1|| [PropertyA] ..." /> </appSettings> in aspx Response.Write("test="); Response.Write(ConfigurationManager.AppSettings ["ApplicationA"]); Response.End(); output test=[Application Name]:MyApp1|| [PropertyA] ... So, where is the problem? (.net 2.0) Alexey Smirnov |
|
|
|
#6 |
|
Posts: n/a
|
Hello Alexey,
It seems to happen under some circumstance that I dont know of because I copied the text back over the ruined value and saved, and have not experienced this issue since, although when I used the web deployment project and deployed it, the web config in the destination was messed up in the same way. I wonder if this is internmittent functionality? I was hoping to use this as a standard web config value so I write a dll to read these values into a class library and include that in my project, then simply refer to the values using the hierarchy that I define in the object produced by the library. Nick. "Alexey Smirnov" <> wrote in message news:fd83a068-1376-422c-b173-... On Nov 5, 9:16 pm, "Nick Large" <msnew...@nospam.nospam> wrote: > Hello Microsoft. > > In a web config file, I intend to set a value in the appsettings as such: > > <add key="ApplicationA" > value="[Application Name]:MyApp1|| > [PropertyA] > ... " > > When I compile, it replaces the CRLF with 
 and pushes the whole text > for the item onto a single line. I intend on having a moderately large > value in here. > For me it works. in the web.config file <appSettings> <add key="ApplicationA" value="[Application Name]:MyApp1|| [PropertyA] ..." /> </appSettings> in aspx Response.Write("test="); Response.Write(ConfigurationManager.AppSettings ["ApplicationA"]); Response.End(); output test=[Application Name]:MyApp1|| [PropertyA] ... So, where is the problem? (.net 2.0) Nick Large |
|
|
|
#7 |
|
Posts: n/a
|
I use a delimiter but I find that the most revolting thing that a programmer can do is have their code stretch so far along that by the time you have reached the middle of the code you have already forgotten about the begining of the code. Microsofts 'Code Complete' book outlines this, but their XML files do not abide by this rule.
Thanks for the suggestion but I go by the rule that if you have to use the horizontal scrollbar, that your code needs reformatting, period. Its the same as saying if I write the same section of code 100 times then I should maybe put that section in a function and call it instead. It is about cutting down into palatable chunks. Nick. "germ" <> wrote in message news:%... forget the line feeds and use just use a delimiter <add key="ApplicationA" value="[Application Name]:MyApp1|[PropertyA] "Nick Large" <> wrote in message news:... Hello Microsoft. In a web config file, I intend to set a value in the appsettings as such: <add key="ApplicationA" value="[Application Name]:MyApp1|| [PropertyA] ... " When I compile, it replaces the CRLF with 
 and pushes the whole text for the item onto a single line. I intend on having a moderately large value in here. Before anyone asks why I need this it is because, instead of having multiple keys that essentially relate to the same object, I intend on creating one single key with multiple internal values in a preset structure that I can use as a standard format. I can include stuff like connection string information and the such. I have tried the standard method and it sucks. When you look at a web.config file that has information on a complex application it gets really difficult to read the values, knowing what goes with what. This way I can group all the information together in one string, which makes sense logically. I want to know either how to stop the designer from reordering my value-text when I compile, or how do I concatenate values in the web config, like I would in a section of code, thus: mytext = oldtext & ',' & appendedtext. Eg. can I use <add key="ApplicationA" value="[Application Name]:MyApp1||" + "[PropertyA] " ... " Thanks in advance Nick Large |
|
|
|
#8 |
|
Posts: n/a
|
Hi Allen.
This issue appears to be intermittent. I will do my best to try and repro this properly again. It had this behavior the first time I deployed, so I copied the correct layout back over it and recompiled and have not gottent the saame issue since, but, as I say I will try and repro again and reply back. I dont think that what you point it is entirely what I ask but I will leave it until I can repro with 100% accuracy before I continue with this post. Thanks. "Allen Chen [MSFT]" <> wrote in message news:... > Hi Nick, > >>Hello Microsoft. >>In a web config file, I intend to set a value in the appsettings as such: >><add key="ApplicationA" >> value="[Application Name]:MyApp1|| >> [PropertyA] >> ... " >>When I compile, it replaces the CRLF with 
 and pushes the whole text > for the item onto a single line. > > Based on my test, normal ASP.NET Application will not change CRLF in its > web.config with 
 after compile. My guess is you're using Web > development project, right? If so please refer to my previous case to > learn > how to use custom task to replace a string in web.config: > > http://www.microsoft.com/communities...aspx?dg=micros > oft.public.dotnet.framework.aspnet&tid=dd83befb-d870-40dc-bcb4-8a49fc5f85d4& > cat=&lang=&cr=&sloc=&p=1 > > Your probably need to write a custom action to do this. Please use > Reflector to view the source code of: > > MSBuild.ExtensionPack.FileSystem.File > > and write your custom action class. > > Please let me know whether my understanding is correct and whether above > approach can solve this issue. > > Regards, > Allen Chen > Microsoft Online Support > > Delighting our customers is our #1 priority. We welcome your comments and > suggestions about how we can improve the support we provide to you. Please > feel free to let my manager know what you think of the level of service > provided. You can send feedback directly to my manager at: > . > > ================================================== > Get notification to my posts through email? Please refer to > http://msdn.microsoft.com/en-us/subs...#notifications. > > Note: MSDN Managed Newsgroup support offering is for non-urgent issues > where an initial response from the community or a Microsoft Support > Engineer within 2 business day is acceptable. Please note that each follow > up response may take approximately 2 business days as the support > professional working with you may need further investigation to reach the > most efficient resolution. The offering is not appropriate for situations > that require urgent, real-time or phone-based interactions. Issues of this > nature are best handled working with a dedicated Microsoft Support > Engineer > by contacting Microsoft Customer Support Services (CSS) at > http://msdn.microsoft.com/en-us/subs.../aa948874.aspx > ================================================== > This posting is provided "AS IS" with no warranties, and confers no > rights. > > > > Nick Large |
|
|
|
#9 |
|
Posts: n/a
|
Hi Allen.
I did repro the issue with 100% accuracy. I used the web deployment project (Project -> Create Web Deployment Project) which I always use to deploy applications so that I don't have to copy source files to the deployment server, leaving code open. Anyway, if you have a web.config with keys in the appsettings that have newlines in, then deploy, go to the resultant deployment files and open the web.config file, it will add 
 to each spot that you have a newline, therefore messing up your nice structure that you spend so long building in order to avoid fragmenting related data into hundreds of separate web keys, therefore making application development unmanageable. I thought that Visual studio was supposed to be a reliable development tool. I see that this kind of unwanted behaviour shows to the opposite. Any idea how I can deploy my files either without using the Web Deployment tool which messes it up, or how do I find and turn off the option "please mess with my files" - I dont see it anywhere? Thanks, Nick. "Nick Large" <> wrote in message news:... > Hi Allen. > > This issue appears to be intermittent. I will do my best to try and repro > this properly again. It had this behavior the first time I deployed, so I > copied the correct layout back over it and recompiled and have not gottent > the saame issue since, but, as I say I will try and repro again and reply > back. > > I dont think that what you point it is entirely what I ask but I will > leave it until I can repro with 100% accuracy before I continue with this > post. > > Thanks. > > "Allen Chen [MSFT]" <> wrote in message > news:... >> Hi Nick, >> >>>Hello Microsoft. >>>In a web config file, I intend to set a value in the appsettings as such: >>><add key="ApplicationA" >>> value="[Application Name]:MyApp1|| >>> [PropertyA] >>> ... " >>>When I compile, it replaces the CRLF with 
 and pushes the whole text >> for the item onto a single line. >> >> Based on my test, normal ASP.NET Application will not change CRLF in its >> web.config with 
 after compile. My guess is you're using Web >> development project, right? If so please refer to my previous case to >> learn >> how to use custom task to replace a string in web.config: >> >> http://www.microsoft.com/communities...aspx?dg=micros >> oft.public.dotnet.framework.aspnet&tid=dd83befb-d870-40dc-bcb4-8a49fc5f85d4& >> cat=&lang=&cr=&sloc=&p=1 >> >> Your probably need to write a custom action to do this. Please use >> Reflector to view the source code of: >> >> MSBuild.ExtensionPack.FileSystem.File >> >> and write your custom action class. >> >> Please let me know whether my understanding is correct and whether above >> approach can solve this issue. >> >> Regards, >> Allen Chen >> Microsoft Online Support >> >> Delighting our customers is our #1 priority. We welcome your comments and >> suggestions about how we can improve the support we provide to you. >> Please >> feel free to let my manager know what you think of the level of service >> provided. You can send feedback directly to my manager at: >> . >> >> ================================================== >> Get notification to my posts through email? Please refer to >> http://msdn.microsoft.com/en-us/subs...#notifications. >> >> Note: MSDN Managed Newsgroup support offering is for non-urgent issues >> where an initial response from the community or a Microsoft Support >> Engineer within 2 business day is acceptable. Please note that each >> follow >> up response may take approximately 2 business days as the support >> professional working with you may need further investigation to reach the >> most efficient resolution. The offering is not appropriate for situations >> that require urgent, real-time or phone-based interactions. Issues of >> this >> nature are best handled working with a dedicated Microsoft Support >> Engineer >> by contacting Microsoft Customer Support Services (CSS) at >> http://msdn.microsoft.com/en-us/subs.../aa948874.aspx >> ================================================== >> This posting is provided "AS IS" with no warranties, and confers no >> rights. >> >> >> >> > > Nick Large |
|
|
|
#10 |
|
Posts: n/a
|
Hi Nick,
>I thought that Visual studio was supposed to be a reliable development tool. >I see that >this kind of unwanted behaviour shows to the opposite. Any idea how I can >deploy >my files either without using the Web Deployment tool which messes it up, >or how do I find and turn off the option "please mess with my files" - I >dont see it anywhere? Thanks for your update. If you want to use Web Deployment project please refer to my previous reply to work around this issue. Writing a custom action can solve this problem. The action can be reused for other Web Deployment projects. Or you can manually replace the web.config file after msbuild the project. >I always use to deploy applications so that I don't have to copy >source >files to the deployment server, leaving code open. If you don't want to use Web Deployment project I believe you'll not see this issue. It's also possible to publish web project/web site without publishing source code. For web site, you can right click the site node in solution explorer window and select "Publish Web Site". On the Publish Web Site window, uncheck "Allow this precompiled site to be updatable". For web application project, please run the following command to precompile it: aspnet_compiler -p "path of your web application project folder" -v / "path of the output web site folder" Then you can simply copy&paste it to server to publish it. Please let me know if it can solve this issue and feel free to ask if you have additional questions. I'll do my best to follow up. Regards, Allen Chen Microsoft Online Support Delighting our customers is our #1 priority. We welcome your comments and suggestions about how we can improve the support we provide to you. Please feel free to let my manager know what you think of the level of service provided. You can send feedback directly to my manager at: . Allen Chen [MSFT] |
|
![]() |
| Thread Tools | Search this Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Carsoft, PARTS 1-7 A-B, Car Diagnostic and Tunning equipment, Dashboard tools, Workshop manuals | ola@mail.gr | Computer Support | 0 | 11-07-2007 08:59 PM |
| How not to blow a fuse? computers and a multi plug w/ surge protector | jameshanley39@yahoo.co.uk | Computer Information | 3 | 09-19-2007 04:54 PM |
| Mac Stuff CDs, A to Z, updated 2006/November/06, and Win & Mac programs, 'WinMac', 'PC/MaC', 'Win-Mac', 'Multi', 'Multi-Platform', 'MultiFormat', 'MULTIOS', 'HYBRID' | kashumoto_tokugawa | Computer Information | 0 | 11-07-2006 05:08 PM |
| Spoke to Spoke Enhanced Config (ASA-PIX) NEED HELP ASAP!! | T-Mak | Hardware | 1 | 10-27-2006 11:56 AM |
| Burning CD's (Long - error log included) | fiddaman64 | Computer Support | 11 | 05-11-2005 01:49 PM |