var template = html.Partial(...);
string str = template.ToHtmlString();
str = str.Replace("href=\"#\"", "href=\"\\\\#\"");
str = str.Replace("href='#'", "href='\\\\#'");
return new MvcHtmlString(str);
it would be great if someone had a regex or a helper function that could escape all the non-template '#' characters. I would really be unfortunate if I have to duplicate all my partial views just make them template safe.