邮件发送程序&请求超时
我被要求在asp.net上开发一个自动邮件发送程序。它应该发送 5000 封电子邮件,并从数据库中读取地址。肯定会陷入请求超时的困境。所以看来我必须将它转换成Windows应用程序。但我想知道 ajaxizing 这个网络应用程序是否有帮助。如果我编写一个 Web 服务,并且我的 Web 应用程序一次发送 50 个邮件地址的列表。完成后,发送下 50 个,依此类推。这是否有助于解决http请求超时的问题?
I was asked to develop an auto-mail sending program on asp.net. It is supposed to send, say 5000 e-mails reading the addresses from a database. It will sure fall into request timeout tough. So it seems I have to convert it into a windows app. But I'd like to know if ajaxifying this web-app would help. If I write a web service, and my web app sends the mail addresses as lists of 50 at a time. when done, send the next 50 and so on. Would this help to solve the problem of http request timeout?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 Web 服务端点发送电子邮件是一个好主意,无论您是从 aspx 类调用它还是从使用 javascript 的客户端调用它。
只需使用 Web 服务调用来生成一个线程来发送电子邮件并立即返回。
如果您想要视觉进度提示,请编写另一个 ajax 端点或 aspx 页面来显示电子邮件线程的进度状态。
有很多方法可以实现这一目标,您应该能够根据给定的信息想出一种方法。
从 ajax 进行批处理可能会比您想要做的工作更多,并且会增加不必要的复杂性(这绝不是一件好事)。
这很有趣。我可能会增加这个并发布一些代码。
好的,我回来了。给你。 webform ui 和 ajax ui。
这些都不是成品——只是支持故事的一个尖峰。随意弯曲/折叠/旋转。
EmailService.asmx
WebFormUI.aspx
AjaxUI.htm
Using a webservice endpoint to send your emails is a good idea, whether you call it from an aspx class or from the client with javascript.
Simply use the webservice call to spawn a thread to send the emails and return immediately.
If you wanted visual progress cues then write another ajax endpoint or aspx page that will display the status of the email thread's progress.
There are many ways to accomplish this, you should be able to come up with one with the information given.
Batching from ajax is probably going to be more work than you want to do and adds unnecessary complexity (which is never a good thing).
this is interesting. I may spike this and post some code.
Ok, im back. here ya go. both a webform ui and an ajax ui.
None of this is meant to be finished product - is a spike to support a story. bend/fold/spindle at will.
EmailService.asmx
WebFormUI.aspx
AjaxUI.htm
那么用户必须保持浏览器窗口打开,直到所有电子邮件发送完毕?听起来不太好。我将使用由 cron 运行的守护进程或简单脚本来解决这个问题(并检查数据库是否有要发送的内容),在 Windows 上我希望你可以做类似的事情(编写 Windows 服务等)。这是一个纯粹的服务器端任务,我认为 ajaxifying 它表明 Web 应用程序的作者无法以更好的方式实现它,它甚至可能使您的 Web 应用程序在 thedailywtf.com 上被提及:)
So user will have to leave the browser window open until all the e-mails are sent? Does not sound very good. I would solve this using a daemon or simple script that is run by cron (and checks db if there is something to send), on Windows I hope you can do something similar (write Windows service etc.). This is a purely server-side task, I think ajaxifying it shows that author of the web app wasn't able to make it in a better way, it may even make your web app to be mentioned on thedailywtf.com :)