Paul Hiles
Paul Hiles

Reputation: 9778

Any way to stop Url.RouteUrl from urlencoding route values?

I want to output a placeholder within the url for client-side templating - {{>username}} but the placeholder gets url encoded automatically and the client-side templating breaks.

I can workaround it by passing in say 'username' and then string replacing it with '{{>username}}' and returning IHtmlString but this is far from elegant.

Was hoping for a better solution.

Any ideas Darin (or anyone else)?

Upvotes: 1

Views: 516

Answers (1)

NKeddie
NKeddie

Reputation: 720

@ViewContext.HttpContext.Server.UrlDecode(
    Url.RouteUrl(Model)
)

works for me, perhaps not any cleaner than your other solution.

Test:

Normal: /Value=%3C%40%24(%5E%25%24

Decoded: /Value=<@$(^%$

Upvotes: 1

Related Questions