0

我正在 ASP.NET MVC 中构建一个自定义 CMS,其中一个要求是内容有一个开始和结束日期,该日期指示页面是否出现在网站上。最好的方法是什么?我应该运行某种计时作业来根据其发布日期标记页面的状态吗?有人对此事有任何资源或建议吗?

4

2 回答 2

1

为什么不做这样的事情

bool visible = true;
if (startdate > now || enddate < now)
   visible = false;

这样你就不必有另一个过程。

于 2009-09-22T13:33:45.403 回答
0

You seem eager to make model responsible for choosing active items.

Depending on the size (count) of the items you query, to preserve response time.

if you have many items, you better use a windows service to mark active items.

also you can index the column you use to mark active items.

alternatively, you can make the View responsible for displaying or hiding the item

foreach(var item in Model)
if(Item.DisplayAllowed) renderpartial("ItemView",item);
于 2009-09-22T13:34:40.663 回答