Azure Mobile Service web.config不会在服务器上更新

时间:2015-02-11 02:30:43

标签: paypal azure-mobile-services

我在web.config中添加了paypal配置,我可以通过本地服务器连接paypal。

但是当我发布到AMS服务器时,它不起作用。

我收到以下错误

无法解析* .Config文件。确保您已正确配置'paypal'部分。

<paypal>
<settings>
  <add name="mode" value="sandbox" />
  <add name="connectionTimeout" value="360000" />
  <add name="requestRetries" value="1" />
  <add name="clientId" value="xxx" />
  <add name="clientSecret" value="ccc" />
</settings>
</paypal>

的web.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="paypal" type="PayPal.SDKConfigHandler, PayPal" />
    <section name="log4net"         type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
  </configSections>

  <!-- PayPal SDK settings -->
  <paypal>
    <settings>
      <add name="mode" value="sandbox"/>
      <add name="connectionTimeout" value="360000"/>
      <add name="requestRetries" value="1"/>
      <add name="clientId" value="xxxxx"/>
      <add name="clientSecret" value="cccc"/>
    </settings>
  </paypal>

  <!-- log4net settings -->
  <log4net>
    <appender name="FileAppender" type="log4net.Appender.FileAppender">
      <file value="my_app.log"/>
      <appendToFile value="true"/>
      <layout type="log4net.Layout.PatternLayout">
    <conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] %message%newline"/>
      </layout>
    </appender>
    <root>
      <level value="DEBUG"/>
      <appender-ref ref="FileAppender"/>
    </root>
  </log4net>


  <appSettings>
    <add key="PayPalLogger" value="PayPal.Log.Log4netLogger"/>
    <add key="PreserveLoginUrl" value="true" />   
  </appSettings>

  <system.web>
    <httpRuntime targetFramework="4.5" />
    <compilation debug="true" targetFramework="4.5" />
  </system.web>

  <system.webServer>

  </system.webServer>

</configuration>

1 个答案:

答案 0 :(得分:0)

好的,我已经解决了这个问题。只需使用ConfigurationManager而不是使用PayPal Api ConfigManager.Instance.GetProperties()

// Create the configuration map that contains mode and other optional configuration details.
    public static Dictionary<string, string> GetConfig()
    {
        Dictionary<string, string> configurationMap = new Dictionary<string, string>();
        configurationMap.Add("mode", ConfigurationManager.AppSettings["mode"]);
        configurationMap.Add("clientId", ConfigurationManager.AppSettings["clientId"]);
        configurationMap.Add("clientSecret", ConfigurationManager.AppSettings["clientSecret"]);
        return configurationMap;
        //return ConfigManager.Instance.GetProperties();
    }