创建并发送新闻通讯

发布于 2025-01-06 13:10:16 字数 703 浏览 1 评论 0原文

我想在我的项目中添加新闻通讯功能,以将构建的邮件发送给所有订阅的用户。尽管我根本不期望邮件量很大,但我想这样做是为了将其重新用于发送邮件量可能很大的项目。但是,我很困惑我可以为此使用什么策略。引用此问题的答案:

我不建议发送 ASP.NET 网页,即使您确实在单独的后台启动它 线。我认为你冒着服务器在中间回收你的进程的风险 发送,这会弄乱它。您确实需要编写某种单独的服务或 应用程序发送电子邮件。

这意味着 WCF 服务将是最佳选择,但它是 OData 还是 RIA 服务重要吗? MSDN 文档对于每种类型的用途有点令人困惑。它以 Silverlight 作为使用 RIA 的示例,但仍然表示您也可以独立使用它。

另外,即使我确实以这种方式使用服务,上面关于回收进程的引用是否意味着我无法从 MVC 控制器调用它,因为它会在控制器等待服务时回收进程?理想情况下,我想使用 MVC 创建邮件,将其传递到服务,发送邮件并在 MVC 本身内处理结果。

之后的最后一个问题是我是否可以使用该服务实现表单身份验证。我需要能够控制对该服务的访问,以便其他人无法随机发送新闻通讯。

通过结合使用 WCF 和 MVC 可以实现这些目标吗?

I'd like to add a newsletter feature to my project to send constructed mails to all subscribed users. Although I'm not expecting high volume at all, I'd like to make this with a view to reusing it for projects in which the volume of mails being sent, could be large. However, I am confused as to what strategy I can use for this. To quote the answer to this question:

I would not recommend asp.net webpage to send, even if you do start it in a separate background
thread. I would think you run the risk of the server recycling your process in the middle of the
send, which would mess it up. You really need to write some kind of separate service or
application to send your emails.

This implies a WCF service would be the way to go, but does it matter whether it's an OData or RIA service? The MSDN documentation is a little confusing as to what each type is for. It gives Silverlight as an example to use RIA, but still says you can use it independently too.

Also, even if I do use a service this way, does the above quote about recycling the process mean I wouldn't be able to call it from an MVC controller, as it would recycle the process whilst the controller is waiting for the service anyway? Ideally, I'd like to create the mail with MVC, pass that onto the service, send the mails and process the results within MVC itself.

The last problem after that is whether I can implement forms authentication with the service. I'd need to be able to control access to the service so that other people can't randomly send newsletters.

Are these goals achievable with WCF and MVC combined?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

憧憬巴黎街头的黎明 2025-01-13 13:10:16

在做类似的事情时,并记住我想保证所有内容都已发送。我只是在控制器中设置消息的内容,然后将消息和收件人列表(或者在本例中是定义收件人的过滤器)写入数据库。

然后,我有一个在 ASP(在我的例子中是 Windows 服务)之外运行的完全独立的进程,它定期检查数据库中的发送请求、发送它们并将它们标记为已发送。

显然,MVC 控制器负责处理所有身份验证问题。一旦发送请求被记录到数据库中,就假定它已获得完全授权。

您可以通过使用 WCF 在 ASP 和 Windows 服务之间进行通信来完成类似的事情,但我认为它过于复杂。很难保证请求最终得到处理。无论如何,您确实需要一个数据库记录来 100% 确定这一点 - 因此该记录也可能是您的消息。您通常也不需要实时触发电子邮件发送。

When doing something similar, and bearing in mind I want to guarantee everything is sent. I just set up the contents of the message in my controller, and then write the message and list of recipients (or in this case a filter that defines the recipients) into a database.

Then I have an entirely separate process running outside of ASP (a Windows service in my case) which periodically checks the database for send requests, sends them, and flags them as sent.

Obviously the MVC controller takes care of all the authentication issues. Once a send request is logged in the database it is assumed to be fully authorised.

You could do a similar thing by communicating between ASP and the Windows service using WCF, but I think it's overly complex. It's harder to guarantee the request is eventually handled. You really need a database record to be 100% certain of this anyway - so that record might as well be your message. You also don't generally need real time triggering of the email send.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文