开发者

Dynamically Compiling an ASP.NET MVC View

开发者 https://www.devze.com 2022-12-14 19:29 出处:网络
I want to create a templating engine which sits on top of the asp.net webforms view engine. This is a bit of a shim to simplify an existing XSL based architecture. Instead of using XSL stylesheets, I\

I want to create a templating engine which sits on top of the asp.net webforms view engine. This is a bit of a shim to simplify an existing XSL based architecture. Instead of using XSL stylesheets, I'll use views. Essentially an end user will create a template by submitting aspx view code to my application. I would like to compile that view to a开发者_如何学C C# class and then render the HTML. Obviously the MVC framework is doing this for aspx files in the views folder but I don't know if that compiling functionality is exposed. Does anyone know how to manually compile a view stored in a string to a C# class or assembly?


Phil Haack has an example using the DLR. This means you're using Ruby or Python instead of C#, but it does work.

0

精彩评论

暂无评论...
验证码 换一张
取 消