jueves, 12 de septiembre de 2013

ASP.NET - Uso del app.config

Se añaden las variables en el app.config




 <?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <configSections>
        <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
            <section name="SinonimoNIFProgramado.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
        </sectionGroup>
    </configSections>
  <appSettings>
    <add key="serverUrl" value="http://127.0.0.1/CrmService.asmx" />
    <add key="usuario" value="xx" />
    <add key="password" value="xx" />
    <add key="dominio" value="xx" />
    <add key="organizacion" value="xx" />
  </appSettings>
  <applicationSettings>
      <SinonimoNIFProgramado.Properties.Settings>
            <setting name="SinonimoNIFProgramado_CrmSdk_CrmService" serializeAs="String">
                <value>http://127.0.0.1/MSCrmServices/2007/CrmService.asmx</value>
            </setting>
        </SinonimoNIFProgramado.Properties.Settings>
    </applicationSettings>
</configuration>



Se utilizan en el código


usuario = System.Configuration.ConfigurationSettings.AppSettings["usuario"];

No hay comentarios:

Publicar un comentario