簡體   English   中英

ASMX Web服務的配置文件

[英]config file for ASMX web service

因此,我在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>

我從“ from”位置讀入。 如果我將其更改為

string from = @"C:\images\new";

它完美地工作。

這真讓我抓狂。

您應該使用WebConfigurationManager類而不是ConfigurationManager 它的接口基本相同。

string notFrom =  
  System.Web.Configuration.WebConfigurationManager.AppSettings["folder_new"];

您是否嘗試過在配置中使用雙\\? 就像"c:\\\\images\\\\new"

ConfigurationManager用於處理程序集的應用程序配置文件,而不是Web.config文件。 請改用WebConfigurationManager

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM