Summary
Add HtmlEncode overloads to HttpServerUtility (and its Base/Wrapper mirrors) so code migrating from System.Web that calls Server.HtmlEncode(...) compiles and runs against the adapters without changes.
I was thinking of using WebUtility.HtmlEncode in the methods but do you think it would be better to use HttpUtility.HtmlEncode instead?
Motivation and goals
We are migrating an ASP.NET application to CoreWebForms. We use Telerik UI and some of their components such as RadAjaxLoadingPanel depends on using System.Web.HttpServerUtility.HtmlEncode(System.String). Adding HtmlEncode to HttpServerUtility would help us greatly with the migration.
Example:
System.MissingMethodException: Method not found: 'System.String System.Web.HttpServerUtility.HtmlEncode(System.String)'.
at Telerik.Web.SkinRegistrar.RegisterStyleSheetReference(ISkinnableControl control, StyleSheetReference reference, StringBuilder cssRegs, Type controlToRegisterType)
In scope
string? HtmlEncode(string? value) on HttpServerUtility, returning the encoded string (annotated [NotNullIfNotNull("value")]).
void HtmlEncode(string? value, TextWriter output) on HttpServerUtility, writing directly to a TextWriter.
- Matching virtual declarations on
HttpServerUtilityBase and pass-through overrides on HttpServerUtilityWrapper.
- Backing implementation delegated to
System.Net.WebUtility.HtmlEncode.
Out of scope
I was thinking not to include HtmlDecode overloads here but if you think it should be done simultaneously we can do it.
Risks / unknowns
- WebUtility or HttpUtility
- Should we use the signature of the old method
string HtmlEncode(string s) or match the signature to WebUtilitys HtmlEncode string? HtmlEncode(string? value)
- Unsure about other unknowns or risks. Old HttpServerUtility had these methods.
Examples
HttpContext.Current.Server.HtmlEncode(value)
System.Web.HttpServerUtility.HtmlEncode(value)
Summary
Add
HtmlEncodeoverloads to HttpServerUtility (and its Base/Wrapper mirrors) so code migrating fromSystem.Webthat callsServer.HtmlEncode(...)compiles and runs against the adapters without changes.I was thinking of using
WebUtility.HtmlEncodein the methods but do you think it would be better to useHttpUtility.HtmlEncodeinstead?Motivation and goals
We are migrating an ASP.NET application to CoreWebForms. We use Telerik UI and some of their components such as
RadAjaxLoadingPaneldepends on usingSystem.Web.HttpServerUtility.HtmlEncode(System.String). AddingHtmlEncodetoHttpServerUtilitywould help us greatly with the migration.Example:
In scope
string? HtmlEncode(string? value)onHttpServerUtility, returning the encoded string (annotated[NotNullIfNotNull("value")]).void HtmlEncode(string? value, TextWriter output)onHttpServerUtility, writing directly to aTextWriter.HttpServerUtilityBaseand pass-through overrides onHttpServerUtilityWrapper.System.Net.WebUtility.HtmlEncode.Out of scope
I was thinking not to include
HtmlDecodeoverloads here but if you think it should be done simultaneously we can do it.Risks / unknowns
string HtmlEncode(string s)or match the signature toWebUtilitys HtmlEncode string? HtmlEncode(string? value)Examples
HttpContext.Current.Server.HtmlEncode(value)System.Web.HttpServerUtility.HtmlEncode(value)