Creación de variables personalizadas en web.archivo de configuración?
Quiero crear una variable en web.archivo de configuración y usar esa variable en formularios web. ¿Cómo puedo lograr esto??
28
3 answers
En la web.config:
<appSettings>
<add key="message" value="Hello, World!" />
</appSettings>
En cs:
string str = ConfigurationManager.AppSettings["message"].ToString();
60
Author: DmitryK,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-12-04 09:25:06
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-12-04 09:25:06
Usted puede intentar así:
<appSettings>
<add key="id" value="12762"/>
<add key ="url" value="http://localhost:10982/Redirect.aspx"/>
</appSettings>
Entonces puedes usar
using System.Configuration;
Y úsalo así:
string id=ConfigurationManager.AppSettings["Id"].ToString();
string url=ConfigurationManager.AppSettings["Url"].ToString();
13
Author: Rahul Tripathi,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-03-07 12:11:06
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-03-07 12:11:06
FYI: Las respuestas aceptadas para acceder a la web.los datos de configuración se consideran "obsoletos" ahora y deben reemplazarse por:
Ejemplo:
En la web.config:
<appSettings>
<add key="message" value="Hello, World!" />
</appSettings>
En c#:
ConfigurationManager.AppSettings["message"]
Referencia: ConfigurationSettings.AppSettings es obsoleto, advertencia
4
Author: AndyRBlank,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-05-23 10:31:22
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-05-23 10:31:22