Answer the question
In order to leave comments, you need to log in
RazorEngine - how to disable the use of Namespace when generating a page?
Good afternoon.
I'm using RazorEngine in my solution to generate dynamic pages from a database.
The pages themselves (Views), ordinary users of the site can edit in their account.
(Used to generate PDF files, DOC files, and the MasterPage of their personal page).
Example:
<p>Total to pay: @Model["PAYABLE"] @Model["CURRENCY"]</p>
@foreach(string link in Model.StylesLinks){
<link rel="stylesheet" href="@link" />
}
@foreach (System.Configuration.ConnectionStringSettings conn in System.Configuration.ConfigurationManager.ConnectionStrings)
{
@:@conn.ConnectionString<br/>
}
Type sys = Type.GetType("Sys" + "tem.Configuration.ConfigurationManager");
Answer the question
In order to leave comments, you need to log in
You should not give users the opportunity to write views on the break. Even if you start rendering pages in a separate AppDomain, cutting off the rights to execute malicious code, there is always a chance that the user will write something massive that will load the processor core by 100%, which will make the site unavailable.
It is much more reliable (but also more difficult, of course) to make your own Domain Specific Language, which will extend plain HTML with special constructs necessary for your application.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question