一切都应该很好,但是我的 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
网络配置:
<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("someone@domain.nl");
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 实例并调用了类中的 send 方法(MailvCard)
aspx.cs 本身:
// Calls the method at the class
smtp.MailvCard("user@domain.com", "C:\\local\\vCardGenerator.Website" + "\\" + "FirstName_LastName" + ".vcf");
}
如果需要,愿意提供任何其他/更多信息。
真挚地