MvcHtmlString cuts off apostrophe and everything after

194 Views Asked by At

I'm using .NET 4.0 with MVC 4. I have a custom web control pager that returns an MvcHtmlString using MvcHtmlString.Create(...). A sample MvcHtmlString that is returned is:

<div class="pager">
    <a href='/stuff/things?var1=True&var2=henry's%20food&var3=3&page=2'>2</a>
</div>

However, when this is rendered to the page the html is:

<div class="pager">
    <a href='/stuff/things?var1=True&var2=henry>2</a>
</div>

Everything after and including the apostrophe has been cut off. Why is the page rendering the MvcHtmlString this way? How can I get my apostrophe and the rest of the string to render correctly?

1

There are 1 best solutions below

0
On

try this

@Html.ActionLink("things", "stuff", new { var1 = "True", var2 = "henry's food", var3 = "page=2'")