How to configure Web.config in Cordova project?

2

In this question I was recommended to set up the web. config from my Cordova project that Ajax uses. I researched the subject but found nothing of the sort. Can anyone help me?

    
asked by anonymous 05.06.2015 / 16:01

1 answer

0

Set the following to your Web.config :

<configuration>
  ...
  <appSettings>
    ...
    <add key="BaseURL" value="http://localhost:12345/" />
  </appSettings>
</configuration>

Retrieving information:

using System.Configuration;

var baseUrl = ConfigurationManager.AppSettings["BaseURL"];

When deploying, information can be changed through transformation files. In the project, two examples are created: Web.debug.config and Web.Release.config . In this case, to change BaseURL , the setting is as follows for a Web.Release.config file:

<?xml version="1.0"?>

<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
  <appSettings>
    <add key="BaseURL" value="http://urldomeusite.com.br" xdt:Transform="SetAttributes" xdt:Locator="Match(key)" />
  </appSettings>
  <system.web>
    <compilation xdt:Transform="RemoveAttributes(debug)" />
  </system.web>
</configuration>
    
06.06.2015 / 00:02