所以我在 Visual Studio 2010 中创建了一个 Web 服务。要将其部署到 IIS Web 服务器上,我将 service.asmx、web.config 和 bin 复制到服务器(wwwroot 文件夹)。这一切都很好。
我的问题是从 web.config 中读取一个简单的字符串。我的代码是:
在一种方法中,我有:
string from = System.Configuration.ConfigurationManager.AppSettings["folder_new"];
在 web.config 文件中,我有:
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="folder_new" value="C:\images\new" />
</appSettings>
<...other stuff etc...>
</configuration>
我从“从”位置读入。如果我将其更改为
string from = @"C:\images\new";
它完美地工作。
这真让我抓狂。