1

I have a model that has a property like "SomeUrl", it's an absolute url with some parameters in it, something like this for example: http://www.someexternalsite.com/q?param1=value1&param2=value2

My view takes a List and I am trying to use these url's in an anchor tag like this:

<a href="@Model.SomeUrl">my link</a>

The url is being encoded and ends up coming out like this:

http://www.someexternalsite.com/q?param1=value1&amp;param2=value

How do I stop it from doing that?

2 Answers 2

1

Not encoding the & would result in invalid html. In this case the html is correctly encoded. If you want to render a string not encoded use:

@Html.Raw(...)
Sign up to request clarification or add additional context in comments.

Comments

0

Change your link to this:

<a href="@Html.Raw(Model.SomeUrl)">my link</a>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.