读取webconfig中的mailSettings的一个大小写字母问题

ContractedBlock.gif ExpandedBlockStart.gif Code
 Configuration config = WebConfigurationManager.OpenWebConfiguration(this.Request.ApplicationPath);
        MailSettingsSectionGroup smtp 
= (MailSettingsSectionGroup)config.GetSectionGroup("system.net/mailSettings");

        Response.Write(smtp.Smtp.Network.Host);

就是system.net/mailSettings中的system我写成了System导致了一直出错,表面上看都没区别,但是要小心啊。

指定使用默认网络凭据发送电子邮件时所需的适当 SMTP 参数:

<configuration>
  <system.net>
    <mailSettings>
      <smtp deliveryMethod="network" from="ben@contoso.com">
        <network
          host="localhost"
          port="25"
          defaultCredentials="true"
        />
      </smtp>
    </mailSettings>
  </system.net>
</configuration>

 

 

 

ASP.NET 配置文件为 XML 文件。.NET Framework 定义了一组实现配置设置的元素,并且 ASP.NET 配置架构包含控制 ASP.NET Web 应用程序的行为的元素。

默认配置设置在位于 %SystemRoot%\Microsoft.NET\Framework\versionNumber\CONFIG\ 目录中的 Machine.config file 文件中指定。值由子站点和应用程序继承。如果子站点或应用程序中有配置文件,则继承的值不会出现,但可以被重写并可用于该配置 API。

本节描述可以在 Machine.config 文件和应用程序特定的 Web.config 文件中配置的 ASP.NET 配置架构元素。此部分的目录反映了架构的层次结构

 

<system.web>
   <anonymousIdentification>
   <authentication>
   <authorization>
   <browserCaps>
   <caching>
   <clientTarget>
   <compilation>
   <customErrors>
   <deployment>
   <deviceFilters>
   <globalization>
   <healthMonitoring>
   <hostingEnvironment>
   <httpCookies>
   <httpHandlers>
   <httpModules>
   <httpRuntime>
   <identity>
   <machineKey>
   <membership>
   <mobileControls>
   <pages>
   <processModel>
   <profile>
   <roleManager>
   <securityPolicy>
   <sessionPageState>
   <sessionState>
   <siteMap>
   <trace>
   <trust>
   <urlMappings>
   <webControls>
   <webParts>
   <webServices>
   <xhtmlConformance>
</system.web>

转载于:https://www.cnblogs.com/newos/archive/2009/04/25/1443367.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值