我繼承了一個遷移到不同服務器的.NET 3.5 MVC(看起來像MVC版本1)網站。我安裝了SMTP功能(IIS 7),並在IIS 6中啓動了虛擬服務器。回到IIS 7,我確定SMTP電子郵件設置已交付給本地主機,並檢查了防火牆上的端口。仍然收到此消息。由於我以前從未使用過MVC,因此無法找到應發送此郵件的代碼。我不知道在哪裏看。「SendUsing」配置值無效
任何幫助表示讚賞,謝謝!
HttpException (0x80004005): The "SendUsing" configuration value is invalid.
]
System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String methodName, Object[] args) +99
System.Web.Mail.CdoSysHelper.Send(MailMessage message) +1738
System.Web.Mail.SmtpMail.Send(MailMessage message) +273
IPS.Controllers.AccountController.OnAfterResetPassword(String email, String userName, String newPassword) in B:\IPS\Controllers\AccountController.cs:207
IPS.Controllers.AccountController.ForgotPassword(String userName) in B:\IPS\Controllers\AccountController.cs:192
lambda_method(ExecutionScope , ControllerBase , Object[]) +85
System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +17
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +178
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +24
System.Web.Mvc.<>c__DisplayClassa.<InvokeActionMethodWithFilters>b__7() +53
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +258
System.Web.Mvc.<>c__DisplayClassc.<InvokeActionMethodWithFilters>b__9() +20
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +193
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +382
System.Web.Mvc.Controller.ExecuteCore() +123
System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +23
System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +7
System.Web.Mvc.MvcHandler.ProcessRequest(HttpContextBase httpContext) +144
System.Web.Mvc.MvcHandler.ProcessRequest(HttpContext httpContext) +54
System.Web.Mvc.MvcHandler.System.Web.IHttpHandler.ProcessRequest(HttpContext httpContext) +7
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +181
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75
好了,找到了控制器代碼:
[NonAction]
protected virtual void OnAfterResetPAssword(string email, string userName, string newPassword)
{
System.Web.Mail.MailMessage mail = new System.Web.Mail.MailMessage();
mail.To = email;
mail.From = "[email protected]";
mail.Subject = "New Password";
mail.Body = "Here is your new password";
System.Web.Mail.SmtpMail.Send(mail).
}
我把它改爲:
[NonAction]
protected virtual void OnAfterResetPAssword(string email, string userName, string newPassword)
{
System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
mail.To.Add(email);
mail.From = new System.Net.Mail.MailAddress("[email protected]");
mail.Subject = "New Password";
mail.Body = "Here is your new password";
System.Net.Mail.SmtpMail.Send(mail).
}
而且我的web.config:
<system.net>
<mailSettings>
<smtp>
<network host="<FULL HOST IP ADDRESS>" port="25" userName="" password="" />
</smtp>
</mailSettings>
</system.net>
運行與網站這些變化使得EXACT同樣成功CK痕跡......甚至部分地方說,
System.Web.Mail.LateBoundAccessHelper.CallMethod(obj對象,字符串methodName的,對象[]參數)+99
System.Web.Mail.CdoSysHelper。發送(消息MAILMESSAGE)1738
System.Web.Mail.SmtpMail.Send(消息MAILMESSAGE)+273
心不是很奇怪,它仍然說System.Web.Mail ???我不確定MVC是如何工作的。我必須重新編譯或者類似的東西嗎?我甚至使用標準的telnet請求測試了端口25上的SMTP服務器,它工作正常。
感謝您的幫助。
您需要重建該項目,但是您處於正確的軌道上。 – Kev 2011-03-30 09:37:49