0

I cannot use the HtmlEncoder to encode a string in the asp.net core web API. Can I encode it without using the HtmlEncoder?

1 Answer 1

2

I cannot use the HtmlEncoder to encode a string in the asp.net core web API. Can I encode it without using the HtmlEncoder?

To convert a string into an HTML-encoded string, you can use HttpUtility.HtmlEncode method.

var myEncodedString = System.Web.HttpUtility.HtmlEncode(myString);

Besides, if you do not know how to use System.Text.Encodings.Web.HtmlEncoder to encode the supplied string, you can try following code snippet.

var myEncodedString = System.Text.Encodings.Web.HtmlEncoder.Default.Encode(myString);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.