在 ASP.Net 之外使用 ASP.Net 模板?
作为一个简短的介绍,我花了几天时间编写自己的模板解析器/编译器。这是一个有趣的项目(我计划继续下去),但它引发了人们对 ASP.Net(ASPX、MVC 2/3 或其他)如何处理模板以及它是否足够模块化以在不同项目中使用的好奇心。关于这个话题似乎也没有太多讨论,所以为什么不问呢?
ASP.Net 有很多不错的功能:
- 这是一个经过验证的系统,在生产中运行良好
- 模板编译为 MSIL
- 它可以识别文件更改并重新编译
- 强大的调试支持
- 可扩展模板
所以这里有一个问题: 是否可以采用模板解析/编译/调试系统并将其重用于完全不同的目的? ?
As a brief intro, I spent the last few days writing my own template parser/compiler. It's been an interesting project (which I plan to continue) but it sparked some curiosity about how ASP.Net (ASPX, MVC 2/3, or otherwise) handles templates and whether it's modular enough to use in different projects. There also doesn't seem to be much discussion on the topic, so why not ask?
ASP.Net has a lot of nice features:
- It's a proven system that works well in production
- Templates are compiled to MSIL
- It recognizes that files change and recompiles
- Great debugging support
- Extensible templates
So here's a question: is it possible to take the template parsing/compiling/debugging system and reuse it for an entirely different purpose? Is it modular, or is it kind of that's-all-that-asp.net-is and you either get it or you don't?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
ASPX WebForms 页面对于一般用途来说不够灵活。
这是可能的,但是很令人头痛。 (我已经做到了)
新的 Razor 引擎非常灵活;查看用于通用用途的 RazorEngine 项目。
但是,您描述的某些功能(文件更改监视)是 ASP.Net 本身的一部分,而不是 Razor,并且只能在 ASP.Net AppDomain 中工作。
ASPX WebForms pages are not quite flexible enough for general use.
It's possible, but it's a lot of headache. (I've done it)
The new Razor engine is extremely flexible; look at the RazorEngine project for general purpose use.
However, some of the features you're describing (file change monitoring) are part of ASP.Net itself, not Razor, and will only work in an ASP.Net AppDomain.