简体   繁体   English

C#中的动态RSS Feed

[英]Dynamic RSS Feed in c#

What would be a good way to create a dynamic RSS Feed? 什么是创建动态RSS Feed的好方法? Currently, I have coded a function that is able to create a static file, but I am just curious what the best method of running this at certain times/days would be? 目前,我已经编码了一个能够创建静态文件的函数,但是我很好奇在某些时间/日期运行此文件的最佳方法是什么? For example, I create an RSS feed that lists all the items that occur today, and I would like it to populate at 12:01 AM. 例如,我创建了一个RSS提要,其中列出了今天发生的所有项目,我希望它在12:01 AM填充。 I also have another RSS feed I wrote that lists the next item to occur. 我还编写了另一个RSS feed,其中列出了要发生的下一项。

Just for clarification, I have already created the function to actually make the Feeds, I am just looking for a good way to schedule this process to run on a regular, determinable basis. 为了澄清起见,我已经创建了实际制作Feed的功能,我只是在寻找一种很好的方法来安排此过程定期,可确定地运行。

I am programming in C# on the .net 3.5 framework in VS 2008. 我在VS 2008的.net 3.5框架上使用C#进行编程。

@John - I am using WebForms, and I don't really have a good reason for not just writing it like that, I just created the static feeds because that was what I knew how to do. @John-我正在使用WebForms,我并没有真正的理由不只是这样写,我只是创建了静态提要,因为那是我知道的方法。

You can accomplish this with a much easier way. 您可以通过一种更简单的方法来完成此操作。

Just implement a file cache in your handler. 只需在处理程序中实现文件缓存即可。 Set the filename as the creation date of the xml, and ignore the file after desired time. 将文件名设置为xml的创建日期,并在所需时间后忽略该文件。 The first request to rss after invalidation will get the data from your db. 无效后对rss的第一个请求将从数据库中获取数据。

如何使用预定的任务呢?

If you have access to the windows scheduler then create a script for that. 如果您有权访问Windows Scheduler,则为此创建一个脚本。 If not I would create it when the page is first accessed after 12:01 and then use a caching technique for subsequent calls. 如果不是,我将在12:01之后首次访问该页面时创建它,然后对随后的调用使用缓存技术。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM