My understanding is that the Razor markup will encode html strings, but I tried testing it out with following code in MVC view and it did not encode the html strings.
While the first encoded string is behaving correctly since its not handled by Razor engine, but the second string is not being encoded by Razor, and also the <> part at start in last string is not being encoded by Razor.
Question : Why are second and third strings not being encoded by Razor, or am I missing something about how Razor renders html strings?
Razor markup in a MVC View
<script type="text/javascript"></script>
<br />
@("<script type='text/javascript'></script>")
<br />
@("<><script type="text/javascript"></script>")
Rendering of above Razor markup
UPDATE 1
I believe that the following is happening, but not sure (that is, Razor is encoding stuff but its not obvious to user who sees the browser rendered version)
I think the line just after first br that starts with @ is being encoded by Razor and then the browser is decoding it. Also, the third line just after the second br is being encoded by Razor with the already encoded part being doubly encoded, so when browser decodes it, it remains singly encoded but the <> was single encoded so it gets decoded by browser to <>. Does that sound right?
UPDATE 2
When I looked up in Chrome dev tool the response output, it indeed showed that Razor was encoding the strings in parenthesis. The output in Chrome dev tool for the request is as below. So, what I mentioned in UPDATE 1 is what is actually happening. The last string is doubly encoded as the the > is appearing as &gt;And the first string is singly encoded.
So, I was 100% correct in what I suspected was happening in UPDATE 1.
<script type="text/javascript"></script>
<br />
<script type='text/javascript'></script>
<br />
<>&lt;script type=&quot;text/javascript&quot;&gt;&lt;/script&gt;

@(..)means that its an explicit expression - refer Razor syntax - to quote Any content within the @() parenthesis is evaluated and rendered to the output.@(List<int>...)- the<int>bit of course would not be a valid tag