0

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? I'm worry about this way too because one user can have many templates, so this will cause too much ascx files on server. Have anyone point me to the light :D? Thanks.

complez
  • 7,882
  • 11
  • 48
  • 56
  • Need more info! Is the template an .aspx file ? Where is the Replace taking place, in a HttpModule / HttpHandler or somewhere else ? – bang Nov 18 '09 at 11:58
  • Beware of [Premature Optimization](http://en.wikipedia.org/wiki/Program_optimization#When_to_optimize). – Heinzi Nov 18 '09 at 12:02
  • @bang: template is text plain, stored in database. – complez Nov 18 '09 at 12:31

2 Answers2

2

Don't worry about the performance. Be more concerned about XSS attacks.

Will HTML Encoding prevent all kinds of XSS attacks?

Community
  • 1
  • 1
mcintyre321
  • 12,996
  • 8
  • 66
  • 103
0

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

Community
  • 1
  • 1
CPhelefu
  • 128
  • 1
  • 5