title: XSS Prevention .NET Core 2.x and above
body: <p>We have an asp.net core 2.1 web api wherein we have an endpoint to post vendors with sample payload below which gets stored in PostgreSQL DB. Currently, we have identified an XSS vulnerability if we pass a script that we want to restrict and sanitize the payloads. </p>
  
  <p>I searched over the internet but can't find a working solution for .NET Core which helps prevent XSS attack. Can anyone please provide a solution for the same with a sample code block.</p>
  
  <p>Thank you in advance.</p>
  
  <pre><code>[{
      "Vendor1": {
          "Name": "Happy Customer 1 “&gt;&lt;script&gt;alert(“XSS”)&lt;/script&gt;",
          "UIN": ""
      },
      "Vendor2": {
          "Name": "Happy Customer 2 “&gt;&lt;script&gt;alert(“XSS”)&lt;/script&gt;",
          "UIN": ""
      }
  }]
  </code></pre>