Web.Config文件中的多行文本 [英] Multi line text in a Web.Config file

查看:220
本文介绍了Web.Config文件中的多行文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在网页上显示欢迎消息.我想将消息文本保存在Web.Config文件中.文本将包含换行符.

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.

例如

<appSettings>
<add key="Test" value="Hello 

     There

     How are you?"/>
</appSettings> 

但是,当我显示此内容时,它们全部返回1行.

However when I display this it all goes back on 1 line.

有人可以帮忙吗?

我正在使用ASP.Net 4.0

I'm using ASP.Net 4.0

预先感谢

推荐答案

您可以按照Niek所说的做,但是我更喜欢将常量放在您的应用程序中:App_GlobalResources或App_LocalResources.

You can do it as Niek said but I prefer the Constants to be in your Application: App_GlobalResources or App_LocalResources.

然后,您可以支持多种语言,并且一切都很干净...但是,如果您不想每次更改常量时都进行重建,则可以将文本放入数据库或xml文件中.

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.

web.config中的应用程序设置更多地用于应用程序中的设置

Appsettings in web.config are more for settings in an application

这篇关于Web.Config文件中的多行文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆