我正在使用Gmail STMP服务器发送电子邮件.它工作得很好.但是从几天开始,它有时会停止工作.现在,这只是工作5 out of 10时间.
例外: Failure Sending Email
内在例外: Unable to connect to remote server.
在谈到托管技术支持后,他们说他们的服务器上有一个邮件会话限制.这是一个Shared Hosting,所以当它超过所有新连接时都会阻塞.他们说他们正试图修复它.但也说请检查你是谁closing the mail session properly or not.
我调查了它,但没有Close()或Dispose().我还看到没有确认SMTP转移?
如果有关闭邮件会话,请告诉我?或解决此问题的任何解决方法.
更新
我在用 System.Net.Mail
MailMessage msg = new MailMessage();
SmtpClient sc = new SmtpClient("smtp.gmail.com",587);
NetworkCredential info = new NetworkCredential("email","password");
然后还有另一种调用方法sc.Send().
我有[Authorize]属性HomeController,每当我试图访问它时,它会抛出一个NullReferenceException
这真的很奇怪,因为我[Authorize]之前已经使用了很多次而且工作得很好.在这种情况下,唯一的区别是此应用程序使用Windows 7和IIS 7.5托管在我们自己的Web服务器上
这是Stack Trace:
[NullReferenceException:对象引用未设置为对象的实例.]
System.Web.Mvc.AuthorizeAttribute.AuthorizeCore(HttpContextBase httpContext)+38
System.Web.Mvc.AuthorizeAttribute.OnAuthorization(AuthorizationContext filterContext)+160
System.Web.Mvc .ControllerActionInvoker.InvokeAuthorizationFilters(ControllerContext controllerContext,IList`1过滤器,ActionDescriptor actionDescriptor)+155
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext,String actionName)+784976
System.Web.Mvc.Controller.ExecuteCore()+ 159
System .Web.Mvc.ControllerBase.Execute(RequestContext requestContext)+335 System.Web.Mvc.<> c_ DisplayClassb.b _5 ()+ 62 System.Web.Mvc.Async
.<> c_ DisplayClass1.b _0()+ 20
System.Web.Mvc.<> c_ DisplayClasse.b _d()+54
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()+ 453 System.Web.HttpApplication.ExecuteStep(IExecutionStep step,Boolean&completedSynchronously) +371
编辑:
在查看AuthorizeCore方法代码时,似乎AuthorizeCore是NullReferenceException因为它获取NULL 而抛出HttpContextBase.
有可能吗?因为应用程序中的其他所有工作都很好,比如访问数据库,创建auth cookie等.
编辑2:
只有在将其发布到Web Server后才会发生这种情况.在开发过程中,它在Visual Studio中运行得非常好.
我想知道是否可以在phpMyAdmin的登录屏幕上指定主机.
每当我需要连接到不同的服务器时,我必须编辑主机字段config.inc.php.