Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multi line text in a Web.Config file

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

like image 736
Sun Avatar asked May 18 '12 12:05

Sun


People also ask

How do I add a line break in web config?

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&#13;&#10;test message."

Can we have 2 web config?

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.

Where is Aspnet config?

config file is located in the %SystemRoot%\Microsoft.NET\Framework\%VersionNumber%\CONFIG\ directory. In the Machine.


1 Answers

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

like image 171
Gabriel Avatar answered Oct 25 '22 05:10

Gabriel