不开发“博客系统”的三大理由即时生成 aspx 文件
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
为每篇文章生成单独的 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.
.aspx 页面用于动态生成 html(和 javascript 等)。同一小组 .aspx 页面应该为所有博客条目(存储在一系列字段中)生成输出,或者(出于性能原因)预生成的 html 可以存储在 db(最佳)或 .html 页面中。
为每个博客条目生成一个 .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:
CMS 发布平台有两大类:
。
如果你生成静态文件并动态渲染(.aspx),那么混合系统对我来说是毫无意义的——它具有两者的缺点。
There are two broad kinds of CMS publishing platform:
.
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.