I need to display a welcome message on a webpage. I'd like to have the text of the message saved within the Web.Config file. The text will contain line breaks.
e.g.
<appSettings>
<add key="Test" value="Hello
There
How are you?"/>
</appSettings>
However when I display this it all goes back on 1 line.
Can anybody help?
I'm using ASP.Net 4.0
Thanks in advance
You can just use line breaks in the value: add key="msg_test" value="This is test message." You can also use XML encoded characters: add key="msg_test" value="This is test message."
Yes you can have two web. config files in application. There are situations where your application is divided in to modules and for every module you need separate configuration. For example if you have a application which has two modules lets say accounts and sales.
config file is located in the %SystemRoot%\Microsoft.NET\Framework\%VersionNumber%\CONFIG\ directory. In the Machine.
You can do it as Niek said but I prefer the Constants to be in your Application: App_GlobalResources or App_LocalResources.
Then you can have multiple languages support and everything clean... but if you dont want to rebuild every time you change in the constants then you can put the text in the database or xml file.
Appsettings in web.config are more for settings in an application
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With