Web Analytics Made Easy -
StatCounter Issues with HTML Encoding in ASP.NET Core MVC web application - CodingForum

Announcement

Collapse
No announcement yet.

Issues with HTML Encoding in ASP.NET Core MVC web application

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Issues with HTML Encoding in ASP.NET Core MVC web application

    I just started at a new job as a senior .NET developer, and have run into a very puzzling issue with the package System.Text.Encodings.Web.

    The project is in .NET Framework 4.6.1

    The package is showing in the NUGET PACKAGE MANAGER as Installed version 4.5.0, however, the using statement in a .CS file that is trying to use the HtmlEncoder is showing an error with the error text "The type or namespace 'Encodings' does not exist in the namespace 'System.Text'. Are you missing an assembly reference?"

    It also says after trying to build, another error, "The type HtmlEncoder is defined in an assembly that is not referenced, You must add a reference to assembly 'System.Text.Encodings.Web, version=4.0.3, Culture=neutral, and then a public key token after that."

    I tried several different things but none of them worked.

  • #2
    Haven't touched visual studio for a while. It looks to me that you are referencing the wrong binary for system.text. In visual studio, check your references, remove the entry for system.text and then add a reference to the assembly that you have.

    good luck.

    Comment


    • #3
      Wow... this is old, but I suppose since there never seemed to be "closure"....

      I've seen this before. NPM is telling you that the version installed is 4.5.0 but that the project is requiring version 4.0.3.

      You need to "downgrade" the installed version to match what the project has for a requirement. You can do that through NuGet Package Manager.

      Comment

      Working...
      X