asp.net mvc - Unable to decode a URL string encoded by MVC -
i'm passing string url controller view (using model). while string in controller, not encoded, in view url encoded.
url before encoding:
http://app.xpinator.com/facebookpayments/facebookdesktopaddata?paymentcode=s5usd920k&userlocale=en-us&ver=v3.0.1
url after encoding:
http://localhost/facebookpayments/facebookpaymentitemdata?paymentcode=v250usd45000k&userlocale=en-us&ver=v3.0.1
relevant line in view:
<meta property="og:url" content="@model.url" />
i want display decoded url in view. tried using httputility.htmldecode
, httputility.urldecode
, html.raw
- nil worked.
any ideas?
edit:
thanks daniel's comment realized encoding happening when url in meta property. when "displayable" html there no encoding.
anyway, still looking solution.
after realizing problem occurs meta tags, i've found thread: why html.raw escaping ampersand in anchor tag in asp.net mvc 4?
i managed solve problem suggested workaround create entire meta tag part of raw value.
like this:
controller:
model.url = string.format("{0}{1}{2}", "<meta property=\"og:url\" content=\"", paymentitemog.url, "\" />");
view:
<meta property="og:image" content="@model.image" /> @html.raw(model.url) <meta property="og:description" content="@model.description" />
page view-source:
<meta property="og:image" content="http://localhost/content/images/75x75_fulllogo.png" /> <meta property="og:url" content="http://localhost/facebookpayments/facebookpaymentitemdata?paymentcode=v250usd45000k&userlocale=en-us&ver=v3.0.1" /> <meta property="og:description" content="texttexttext" />
now works great.
asp.net-mvc string url view decoding
No comments:
Post a Comment