Sim, uma classe C # de codificação personalizada funcionará corretamente com as bibliotecas Mono .NET 4.0 instaladas no Ubuntu 16.04.
Depois de lutar com o recurso .NET 4.0 HttpEncoder descrito em
[ link
por uma hora, recebi esta exceção:
The actual exception which was being reported was:
System.Web.HttpException: Code generation failed. ---> System.Configuration.ConfigurationErrorsException: Could not load type 'AntiXssEncoder, AntiXssLibrary'.
at System.Web.Util.HttpEncoder.GetCustomEncoderFromConfig () <0x40e99f10 + 0x0015f> in <filename unknown>:0
at System.Lazy'1[T].CreateValue () <0x40e8cc80 + 0x001d2> in <filename unknown>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <0x40ea1490 + 0x00033> in <filename unknown>:0
at System.Lazy'1[T].get_Value () <0x40e8c580 + 0x000cc> in <filename unknown>:0
at System.Web.Util.HttpEncoder.get_Current () <0x40e99c50 + 0x0006f> in <filename unknown>:0
at System.Web.HttpUtility.HtmlEncode (System.String s) <0x40e99b80 + 0x00053> in <filename unknown>:0
at System.Web.HttpException.HtmlEncode (System.String s) <0x40e99ae0 + 0x00047> in <filename unknown>:0
at System.Web.HttpException.FormatFullStackTrace () <0x40e98510 + 0x001cf> in <filename unknown>:0
at System.Web.HttpException.GetHtmlErrorMessage () <0x40e968f0 + 0x001d3> in <filename unknown>:0
--- End of inner exception stack trace ---
at System.Web.Compilation.BuildManager.GenerateAssembly (System.Web.Compilation.AssemblyBuilder abuilder, System.Web.Compilation.BuildProviderGroup group, System.Web.VirtualPath vp, Boolean debug) <0x40eb3f10 + 0x0045f> in <filename unknown>:0
at System.Web.Compilation.BuildManager.BuildInner (System.Web.VirtualPath vp, Boolean debug) <0x40ea7280 + 0x0057b> in <filename unknown>:0
at System.Web.Compilation.BuildManager.Build (System.Web.VirtualPath vp) <0x40ea6c90 + 0x0014b> in <filename unknown>:0
at System.Web.Compilation.BuildManager.GetCompiledType (System.Web.VirtualPath virtualPath) <0x40ea6940 + 0x00093> in <filename unknown>:0
at System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath (System.Web.VirtualPath virtualPath, System.Type requiredBaseType) <0x40ea6800 + 0x00033> in <filename unknown>:0
at System.Web.UI.PageParser.GetCompiledPageInstance (System.String virtualPath, System.String inputFile, System.Web.HttpContext context) <0x40ea6460 + 0x000bb> in <filename unknown>:0
at System.Web.UI.PageHandlerFactory.GetHandler (System.Web.HttpContext context, System.String requestType, System.String url, System.String path) <0x40ea6420 + 0x00027> in <filename unknown>:0
at System.Web.HttpApplication.GetHandler (System.Web.HttpContext context, System.String url, Boolean ignoreContextHandler) <0x40e7e970 + 0x002de> in <filename unknown>:0
at System.Web.HttpApplication.GetHandler (System.Web.HttpContext context, System.String url) <0x40e7e940 + 0x0001b> in <filename unknown>:0
at System.Web.HttpApplication+<Pipeline>c__Iterator1.MoveNext () <0x40e80000 + 0x02a5f> in <filename unknown>:0
Então, eu corrijo essa exceção pesquisando c # Type.GetType (typename, false) Neste URL, [ , @rene escreveu:
"If the type is in the currently executing assembly or in Mscorlib.dll, it is sufficient to supply the type name qualified by its namespace."
"It is adviced to always specify the assemblyname. In the asp.net scenario, if the assemblyname is present in the type parameter it short-circuits to the Type.GetType call which prevents the loading and inspection of all dll's in the bin folder of your webapp."
1. Compiing:
sudo mcs -t:library -r:../bin/System.dll -r:/usr/lib/mono/gac/System.Web/4.0.0.0__b03f5f7f11d50a3a/System.Web.dll -r:../bin/AntiXSSLibrary.dll MyEncoder.cs
que cria o assembly MyEncoder.dll que copio para a pasta bin e adiciona como uma referência externa ao meu csproj. Por favor, não coloque System.Web.dll na pasta bin da sua aplicação ASP.NET.
-
Alterando o encoderType na linha httpRuntime do Web.config para: