简体   繁体   English

asp.net C#-替换文本或Web用户控件

[英]asp.net C# - replace text or web user control

i'm developing a website allow user enter template for their content like this: 我正在开发一个网站,允许用户输入其内容的模板,如下所示:

Name: ${name}
Email: ${email}
Phone: ${phone_number}
...

It was stored into database. 它已存储到数据库中。 When user invoke, engine get it out and replace all flags with fit contents: 当用户调用时,引擎将其取出并用合适的内容替换所有标志:

tpl = tpl.Replace("${name}", customer.Name);
tpl = tpl.Replace("${email}", customer.Email);
...

I'm confusing about performance of this way. 我对这种方式的性能感到困惑。 How about i convert a template to web user control (ascx file with out code behind) and load it when user invoke? 我如何将模板转换为Web用户控件(没有代码的ascx文件)并在用户调用时加载它? I'm worry about this way too because one user can have many templates, so this will cause too much ascx files on server. 我也担心这种方式,因为一个用户可以有许多模板,因此这将导致服务器上的ascx文件过多。 Have anyone point me to the light :D? 有人指出我:D吗? Thanks. 谢谢。

Don't worry about the performance. 不用担心性能。 Be more concerned about XSS attacks. 更关注XSS攻击。

Will HTML Encoding prevent all kinds of XSS attacks? HTML编码会阻止各种XSS攻击吗?

This is easy to do using a placeholder and regex. 使用占位符和正则表达式很容易做到这一点。 Check out my post to a similar question here: 在这里查看我对类似问题的帖子:

Replace a string with a user control 用用户控件替换字符串

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM