I am using ASP.NET 4.0 Web forms. I want to escape </script>
tag in script tag defined on an aspx page. Code as simple as this:
<%@ Page Language="C#" AutoEventWireup="true" Theme="" %>
<script runat="server">
string dfd = @"<script></script>";
</script>
is simply not working. How can I tell the compiler not to count it as server-side script closing tag?
You could just break the string
and concat using the string.Concat
method, for sample:
string dfd = string.Concat("<script>", "</", "script>";
Or if you need to add some code, for sample:
string dfd = string.Concat("<script>", "alert('Hello World!');", "</", "script>";