Here is my code:
@Url.Content("~/AspNetWebForms/ViewPDF.aspx?id=" + docID.ToString() + "&small=True")
I am dynamically building my Manifest file for Application Caching in MVC4. I know it's on the way out (or appears to be) but I do still need to support older browsers.
The site is in MVC, but we do have a couple ASPX pages because we need to use some legacy controls. So in my manifest file I am trying to create a relative path to the ASPX pages using Url.Content(), which seems to work until I need to add a couple parameters and the "&" is encoded. Without the "&" it seems to work (except that it loads/caches the wrong thing).
And since it's a manifest file, I cannot do a redirect, as any redirect causes the application cache to fail.
Even though it's MVC4, I cannot just start with the "~" because it doesn't get parsed as it would in an image or anchor.
At first I thought it was the Url.Content that was encoding the value, but it's actually the Razor engine doing it. Html.Raw corrected it, though I did have to add an empty line afterwards as the line break was lost, too.
@Html.Raw(Url.Content("~/AspNetWebForms/ViewPDF.aspx?id=" + docID.ToString() + "&small=True"))
Paul Abbott's answer lead me to this conclusion so all thanks to him.