You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
DisableEncoding works only for first SerializeObject-call when using same RazorLightEngine
DisableEncoding works only for first SerializeObject-call when using same RazorLightEngine
Hello everyone,
i am currently trying to build several strings using RazorLight and a cshtml-file:
engine.CompileRenderAsync("Assets.Embedded.R4200", layoutParameter)
layoutParameters might contain special characters like '<' or 'ö'. Using both "DisableEncoding()" function when building RazorLightEngine via RazorLightEngineBuilder or using "@(new HtmlString(Model.V02))" inside the cshtml-file works for one call only. All subsequent strings contain those special characters in encoded form (e.g. Ü) I am using the same RazorLightEngine for all calls.
My current workaround is to create a new RazorLightEngine for every call. Trying to change this..
I am logging "engine.Options.DisableEncoding" for every call. It is set to true.
Is it my understanding of Razor that is incomplete (this is the first time I am using it)? Is this the expected behaviour?
I do not exactly know which further information might be useful for help. I am using .net-core 3. Autofac-module is used to create a single instance of RazorLightEngine. I use this entry in my csproj-file:
ItemGroup
None Remove="Assets\Embedded*.cshtml"
EmbeddedResource Include="Assets\Embedded*.cshtml"
ItemGroup
DisableEncoding = true;
as described in readme
https://github.com/toddams/RazorLight#encoding
solves this issue. For me the problem is solved right now. I do not understand the different behaviour yet. However, im fine with that. One might either close this topic or wait for comments providing further information on this.