ASP.net MVC:从DB串执行剃刀? [英] ASP.net MVC: Execute Razor from DB String?

查看:137
本文介绍了ASP.net MVC:从DB串执行剃刀?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在考虑给最终用户放弃局部视图(对照组)进入信息被存储在数据库中的能力。是否有执行从数据库字符串,我得到的剃刀视图的一部分的方式?

I was thinking about giving end users the ability to drop Partial Views (controls) into the information being stored in the database. Is there a way to execute a string I get from the database as part of the Razor view?

推荐答案

我曾问过这个问题previously(这导致我创造RazorEngine)<一个href=\"http://stackoverflow.com/questions/3367106/pulling-a-view-from-a-database-rather-than-a-file\">Pulling从数据库视图,而不是一个文件

Update (I forgot all about this)

I had asked this question previously (which lead me to create RazorEngine) Pulling a View from a database rather than a file

我知道至少有两个: RazorEngine ,的 MvcMailer

I know of at least two: RazorEngine, MvcMailer

我对RazorEngine偏见,因为它是一个我工作过的,但我有一个简单得多的逐一Github上叫的剃刀那样(虽然它仅支持C#)

I have a bias towards RazorEngine as it's one that I've worked on but I have a much simpler one at Github called RazorSharp (though it only supports c#)

这些都是pretty易于使用。

These are all pretty easy to use.

string result = RazorEngine.Razor.Parse(razorTemplate, new { Name = "World" });

MvcMailer

我没有使用过这一个,所以我也没有办法。

MvcMailer

I haven't used this one so I can't help.

象剃刀还支持母版页。

string result = RazorSharp.Razor.Parse(new { Name = "World" }, 
                                       razorTemplate, 
                                       masterTemplate); //master template not required

无论是剃刀那样,也不RazorEngine支持任何MVC的助手,如 HTML 网​​址。由于这些库都应该存在的MVC之外,因此需要更多的工作,让他们与那些助手工作。我不能说什么MvcMailer但我怀疑的情况是一样的。

Neither RazorSharp, nor RazorEngine support any of the Mvc helpers such as Html and Url. Since these libraries are supposed to exist outside of Mvc and thus require more work to get them to work with those helpers. I can't say anything about MvcMailer but I suspect the situation is the same.

希望这些帮助。

这篇关于ASP.net MVC:从DB串执行剃刀?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆