一切都应该很好,但我的web.config给了我这个奇怪的错误。web.config配置错误
如果我确定web.config中的字符串列表很好,我该如何得到这个错误?
错误:
配置错误 说明:该请求提供服务所需的配置文件的处理过程中发生了错误。请查看下面的具体错误细节并适当修改您的配置文件。
Parser Error Message: Unrecognized configuration section stringlist.
Source Error:
Line 6: <connectionStrings/>
Line 7:
Line 8: <stringlist key="SmtpServers">
Line 9: <stringlistItem value="smtp.transip.nl" />
Line 10: <stringlistItem value="localhost" />
Source File: C:\local\vCardGenerator.Website\vCardGenerator.Website\web.config Line: 8
Web.config文件:
<stringlist key="SmtpServers">
<stringlistItem value="smtp.transip.nl" />
<stringlistItem value="localhost" />
</stringlist>
类:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Web.Configuration;
using System.Net.Mail;
using System.Net.Configuration;
using Compulutions.Net;
using Compulutions.Web;
using System.IO;
using System.Web.Mail;
using System.Collections.Generic;
using System.ComponentModel;
using System.Web.Services.Description;
// System.Web.Mail.SmtpMail.SmtpServer
// using System.Web.Mail.SmtpClient;
namespace vCardGenerator.Website.Masterpage
{
public class SendvCard
{ //
public void MailvCard(string recipient, string filename)
{
Mailer smtp = new Mailer("smtpServers");
/* SMTP - port 25 */
smtp.AddAttachment(filename); //.vcf file Path
smtp.FromAddress = new MailAddress("[email protected]");
smtp.Subject = "vCard";
smtp.MailBody = "There is a vCard waiting for you in the attachment!";
smtp.AddRecipient(recipient);
#if !DEBUG
try
{
#endif
smtp.SendMail();
#if !DEBUG
}
catch (Exception ex)
{
Response.Write("Exception Occured: " + ex);
//Responds.Write("Sending vCard Failed, Please try again!")
}
#endif
}
}
}
类似的问题不适合我的描述。 我已经创建SendvCard.cs的实例,并调用在类(MailvCard)发送方法
aspx.cs本身:如果需要的话
// Calls the method at the class
smtp.MailvCard("[email protected]", "C:\\local\\vCardGenerator.Website" + "\\" + "FirstName_LastName" + ".vcf");
}
愿意提供任何其他/更多信息。
真诚
什么是'stringlist'和'stringlistitem'?你是否创建/注册这些有效的配置部分? –
您忘了将字符串列表添加到configSections节点吗? –
是的,我将它们注册为有效的配置部分。 – Lobato