using RazorEngine outside asp.net I'm experiencing this error when I try to write raw html by using @Html.Raw("html string here")
:
Unable to compile template. The name 'Html' does not exist in the current context
Can you help me?
Thanks!
Raw can result in a XSS vulnerability being exploitable since an attacker can craft a special URL containing a malicious JavaScript payload that will be executed by the victim's browser if he or she sends an invalid 2FA confirmation code.
Raw method does not work and I have to use HttpUtility. HtmlDecode(EncodedContent) before I use Html.
The Html. Raw Helper Method is used to display HTML in Raw format i.e. without encoding in ASP.Net MVC Razor. Configuring Bundles. Please refer the following article for complete information on how to configure Bundles in ASP.Net MVC project. Using Bundles (ScriptBundle) in ASP.Net MVC Razor.
Using Html. Raw allows you to output text containing html elements to the client, and have them still be rendered as such. Should be used with caution, as it exposes you to cross site scripting vulnerabilities.
The solution has been found here: https://github.com/Antaris/RazorEngine/issues/34
It's enough to use @(new RawString("html string here"))
or @Raw("html string here")
instead of @Html.Raw("html string here")
.
I hope this helps! Bye
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With