I want to prevent xss in my application. I have an text input for which I should be able to accept for example <script>alert(1)</script>
but as I save this, if I encode it using : System.Web.HttpUtility.HtmlEncode(Me.txtUsername.Text)
I will be able to save the encoded version of this string:
<script>alert(1)</script>
how should I show this later on without letting the script be executed?
if I decode it the script will be executed.
I want to later on show this as <script>alert(1)</script>