I have a URL I would like to render in an anchor tag as-is in a Razor view. I would have thought Html.Raw would be the way to go:
@{
string test = \"http
Like this:
@{
string test = "http://someurl.com/someimage.png?a=1234&b=5678";
}
produces valid markup:
But this doesn't work. The ampersand gets encoded and the HTML is rendered as:
But that's exactly how a valid markup should look like. The ampersand must be encoded when used as an attribute. Don't worry, the browser will perfectly fine understand this url.
Notice that the following is invalid markup, so you don't want this: