不开发“博客系统”的三大理由即时生成 aspx 文件

发布于 2024-08-24 10:28:03 字数 352 浏览 2 评论 0原文

In this question the OP implies that he wants to base the blog system he is developing on automatic creation of .aspx files, one for each new blog entry. In my answer to his question (which is related to something else), I told him that I would discourage him from using such an approach, but without giving any real reasons. He is now wanting reasons why it is not a good idea, and I'm using this question to see if the community can come up with a compelling enough list of reasons for him to use another approach, such as one using a dbms, code-reuse, url-rewriting, MVC, and what not.

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

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

发布评论

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

评论(3

夏末的微笑 2024-08-31 10:28:03

为每篇文章生成单独的 ASPX 文件对服务器资源的使用效率很低:

  • 每个新的 aspx 文件都将被编译为 DLL。这意味着编译文章的额外执行时间开销 + 通过重新创建包含此新 DLL 的新 AppDomain 的内存开销

  • 可以将 ASP.Net 配置为在单个 DLL 文件中编译所有 ASPX 文件,但这将是更糟糕的是:每次生成新文章时,所有文章都必须重新编译

一种更可接受的解决方案(但即使如此,我也不会推荐)是生成静态 .html 文件。

Generating separate ASPX files for each article is inefficient use of server resources:

  • every new aspx file will get compiled to a DLL. This means an additional execution time overhead for compiling the article + memory overhead through recreation of a new AppDomain that contains this new DLL

  • it's possible to configure ASP.Net to compile all ASPX files in a single DLL file, but that would be even worse: ALL articles will have to be recompiled every time a new article is generated

A more acceptable solution (but even then, not the one I would recommend) would be to generate static .html files.

呆橘 2024-08-31 10:28:03

.aspx 页面用于动态生成 html(和 javascript 等)。同一小组 .aspx 页面应该为所有博客条目(存储在一系列字段中)生成输出,或者(出于性能原因)预生成的 html 可以存储在 db(最佳)或 .html 页面中。

为每个博客条目生成一个 .aspx 页面就是生成用于生成内容的工具。对于任何一个正常人来说,这没有任何意义。该系统将产生不必要的开销。 在不知道他的确切计划的情况下,我仍然可以确定至少有以下一些情况适用:

  • .aspx 页面中的代码重复,更新布局/行为非常困难 站点
  • IIS 必须处理并不断重新编译许多额外的 .aspx 页面,从而导致
  • 产生大量不必要的开销。搜索将是一场噩梦,因为内容将在文件中。设置起来很困难,而且永远不会有效率。
  • 编辑、添加评论、审核将是。 。 。真的很难。
  • 安全将会变得复杂

.aspx pages are for dynamically generating html (and javascript etc.). Either the same small set of .aspx pages should generate output for all the blog entries (stored in a series of fields) or (for performance reasons) pre-generated html could be stored in the db (best) or .html pages.

Generating an .aspx page for each blog entry is generating the tool for generating content. It doesn't make sense for any normal. There will be needless overhead in that system. Without knowing his exact plan, I can still be sure that at least some of the following apply:

  • duplication of code in the .aspx pages, great difficulty updating the layout/behavior of the site
  • substantial and needless overhead from IIS having to process and constantly recompile many extra .aspx pages.
  • searching will be a nightmare, as the content will be in files. Difficult to set up and it will never be efficient.
  • editing, adding comments, moderating will be . . . really hard.
  • security will be complicated
白龙吟 2024-08-31 10:28:03

CMS 发布平台有两大类:

  • 静态生成内容的平台。一些发布平台静态生成内容。在这种情况下,生成的文件不是动态的,应该是 HTML 文件。系统必须能够重新生成所有内容,例如,如果模板发生更改。曾经有一段时间,这个解决方案有一些优点:
    • 安全性:安全性在文件系统级别进行管理
    • 搜索:全文搜索很容易,因为一切都是基于文件的
    • 性能:使用更少的 CPU。
    • 交互性:不可能
    • 内容传播:现在建立或选择此类平台的唯一原因是内容是否需要通过网络以外的其他渠道传播,例如 CD、可下载期刊、等等

  • 动态呈现内容的人员。对于网站来说,最简单的方法就是动态渲染页面。
    • 安全性:可以使用复杂的方案等来检查安全性。
    • 搜索:搜索系统已经发展并与异构源很好地集成:可以是数据库、文件等中的全文。
    • 性能:这不再是问题。
    • 交互性:这更加灵活:内容可以适应访问用户,人们可以对页面进行评分、添加评论等。
    • 内容传播:当然需要在线

如果你生成静态文件并动态渲染(.aspx),那么混合系统对我来说是毫无意义的——它具有两者的缺点。

There are two broad kinds of CMS publishing platform:

  • Those who generate the content statically. Some publishing platform generate the content statically. In this case the generated files are not dynamic and should be HTML files. The system must have the ability to regenerate everything, for instance, if a template changed. There was a time when this solution had some advantages:
    • security: security is managed at the file system level
    • search: fulltext search was easy because everything was file-based
    • performance: uses less CPU.
    • interactivity: not possible
    • content dissemination: the only reason now to build or choose such platform is if content need to be disseminated through other channel than the web, e.g. CD, downloadable journal, etc.

.

  • Those who render the content dynamically. For web site, the easiest way is to render the page dynamically.
    • security: security can be checked using complex scheme, etc.
    • search: search system have evolves and integrate nicely with heterogeneous sources now: can be full text in database, files, etc.
    • performance: this is no more an issue.
    • interactivity: this is a lot more flexible: content can be adapted to the visiting user, people can rate the page, add comment, etc.
    • content dissemination: needs to be online, of course

A hybrid system were you generate statically file that will be rendered dynamically (.aspx) is to me a non-sense -- it has the disadvantages of both.

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