I have a resource on an external server that will need to be used for a dynamic background-image, and the link to the resource contains a query string.
When I pass the string into url() property it is not encoded, but when the browser parses the resource link if forces encoding which results in a broken query string.
I can use the same resource link in an src property and everything behaves like it should. I've tried running it through various HttpUtility functions but it always gets (specifically &'s) encoded.
parsedLink:
http://localhost:59940/remote.axd/blobstorage.blob.core.windows.net/media/1000/someimage.jpg?crop=0,0,0.61914062500000022,0.0000000000000005921189464667&cropmode=percentage&width=750&height=640&rnd=131413923870000000)
Razor automatically HTML encodes strings that you render on the page. From what you describe, it does sound as though it may not encode strings in an src attribute (I haven't seen that).
Anyway, since mvc 3, if you wrap a string in
@Html.Raw(myString)
It will render without encoding.