写&通过reponse.write执行代码 [英] Write & Executing code by reponse.write

查看:49
本文介绍了写&通过reponse.write执行代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我想在<%%>之间插入代码asp.net.在sqlserver数据库中,我想在page.aspx中将其写入并执行
谢谢
例如

Hi
I want insert code asp.net between <% %> in a sqlserver database and i wana write it in a page.aspx and execute it
thank''s
for example

<%
String body="<% Response.Write(\"Hello world\") %>";
Reponse.Write(body);
%>


在输出中,我想要这个结果


In output i want this result

Hello world 


不是


not

<% Response.Write(\"Hello world\") %>;

推荐答案

我在这里做了一些猜测,但我想您真的想说您想在数据库中使用文本形式的代码,然后将其包括在内将代码放在<%;内部的代码中%>标签.

鉴于上述假设成立,我可以告诉您:是的,虽然可以做到,但要付出一定的代价.每次您想要更改aspx页面上的插入代码时,都必须运行另一个页面,通过重写aspx文件的内容来启动更改,并且在重写之后您可以重定向到该页面,这就是痛苦的开始:
ASP.NET意识到对文件进行了更改,需要重新编译它,这需要一些时间.即使很少发生更改,即使我仍然不想考虑这种情况,这也是可以忍受的.如果每个页面请求都需要更改代码,则可以清楚地忘记它.

不过,请考虑使用此库: FLEE快速轻量表达评估器 [ ^ ].这个奇妙的库使您可以动态编译表达式,然后动态调用它们.由于表达式的源代码是纯文本,因此您可以将它们保留在数据库中,并动态加载它们以进行编译和执行.出于性能原因,您应该考虑对已编译位进行某种缓存,尽管此过程还会带来一些开销.最好的部分当然是它的执行速度与正常编译的代码一样快.

希望对您有帮助.如果您有任何问题,请给我留言.

最好的问候,
Manfred
I doing a bit of guessing here but I think you really meant to say you want to have code in text form inside the database and then include that code in your aspx page by placing it inside <%; %> tags.

Given the above assumption holds true I can tell you that: Yes it can be done, but it comes at a cost. Every time you wanted to change the inserted code on an aspx page you would have to run another page that initiates the changes by rewriting the content of the aspx file and after the rewrite you could redirect to that page and that is where the pain begins:
ASP.NET realizes that a change has been made to the file and needs to recompile it which takes some time. This can be tolerable if the changes are seldom even though it still is a scenario I''d rather not think about. You can clearly forget about it if the code changes are due on every page request.

Please consider using this library though: FLEE Fast Lightweight Expression Evaluator[^]. This fantastic library lets you compile expressions on the fly and then call them dynamically. Since the source code for the expressions is plain text you can keep them in your database and load them dynamically to compile and execute. For performance reasons you should consider some kind of caching for the compiled bits though as this process also introduces some overhead. The best part is of course that it executes as fast as normally compiled code.

I hope this was helpful to you. If you have any questions leave me a comment.

Best Regards,
Manfred


我想将页面代码存储到类似php中的joomla的数据库中
i wanna stock page code into database like joomla in php


这篇关于写&amp;通过reponse.write执行代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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