【发布时间】:2013-03-05 06:37:47
【问题描述】:
以下代码在本地运行良好,但是当我将其发布到服务器时,我收到错误 The name 'WebMail' does not exist in the current context。不知道为什么会发生这种情况,特别是如果它在本地工作。感谢您的帮助。
public void SendMessage()
{
WebMail.SmtpServer = SmtpServer;
WebMail.UserName = ServerUsername;
WebMail.Password = ServerPassword;
WebMail.From = this.From;
var recipents = string.Join(",", this.To);
WebMail.Send(recipents, this.Subject, this.Body);
}
【问题讨论】:
-
在
WebMail上按 F12 并准确查看它所在的命名空间和 DLL。确保在您的服务器上部署和/或 GAC'ed DLL。 -
System.Web.Helpers,因为它在 system.web 它应该在服务器上
-
虽然问题不大,但请尝试将其显式添加到 web.config。我不记得触发问题的情况,但我已经看到服务器上代码中的代码抛出异常并在添加到 web.config 时开始工作的问题。 (可能不是问题,但可能值得检查。)
-
我确保
添加了 -
您是否在服务器上安装了 asp.net mvc 或至少安装了所需的 .dll,例如System.Web.Helpers.dll? blog.discountasp.net/…
标签: c# asp.net-mvc