Skip to content

Where is HttpContext.Server.HtmlEncode #820

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
PrimeObjects opened this issue Aug 11, 2015 · 9 comments
Closed

Where is HttpContext.Server.HtmlEncode #820

PrimeObjects opened this issue Aug 11, 2015 · 9 comments

Comments

@PrimeObjects
Copy link

How can I do HtmlEncode now in ASP.NET 5?

Thank you
Gary

@Eilon
Copy link
Member

Eilon commented Aug 11, 2015

There's an HTML encoder that you can acquire through DI.

However, depending on where you are in the system, there are often easier ways to get to it. From where do you want to do HTML encoding? An MVC controller? Middleware? A POCO class?

@PrimeObjects
Copy link
Author

Eilon,

Thank you for the reply.
I'm doing it in controller for now. please let me know how to do the DI for this function (e.g what should I do in startup.cs and what should I pass in constructor).


May I have a suggestion here? Could you guys provide a table to show how to do some poplar functions between ASP.NET 4 and 5. It will lower the learning curse and improve the adoption of ASP.NET 5.

For example,

HTMLEncoding
ASP.NET 4: HttpContext.Server.
ASP.NET 5: DI, how to ...

CultureInfo
ASP.NET 4: ....
ASP.NET 5: not supported yet (?) Any workaround?

Cache:
ASP.NET 4: HttpContext.Cache
ASP.NET 5: DI, how to ...

Thanks lot
Gary

@holajan
Copy link

holajan commented Aug 19, 2015

There is Microsoft.Framework.WebEncoders.HtmlEncoder.Default.HtmlEncode(). But where is HtmlDecode?

@Eilon
Copy link
Member

Eilon commented Oct 19, 2015

@blowdart thoughts on having matching encode/decode APIs for all the encoder stuff? This is all in the BCL now, but we can provide input (and perhaps implementations, if desired).

There are currently HTML, JavaScript, and URL encoders here: https://github.com/dotnet/corefx/tree/master/src/System.Text.Encodings.Web/src/System/Text/Encodings/Web. But no decoders.

@blowdart
Copy link
Contributor

We is core duplicating work we have already done? (https://github.com/aspnet/HttpAbstractions/tree/dev/src/Microsoft.Extensions.WebEncoders.Core)

There needs to be a sole implementation, and ours, we generate from the specs, so it's up to date.

(but yea, there should be decodes too).

@Eilon
Copy link
Member

Eilon commented Oct 20, 2015

@blowdart we're removing ours and will call into the ones in CoreFx (we moved the code there).

Do you want to log a bug for CoreFx on decoders with any relevant info?

@aspnet-hello
Copy link

This issue is being closed because it has not been updated in 3 months.

We apologize if this causes any inconvenience. We ask that if you are still encountering this issue, please log a new issue with updated information and we will investigate.

@davidalpert
Copy link

davidalpert commented Dec 31, 2017 via email

@davidalpert
Copy link

davidalpert commented Dec 31, 2017 via email

@ghost ghost locked as resolved and limited conversation to collaborators Dec 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants