Reputation: 3917
I have a site where users can supply a URL of their choice.
I'm sure it's a security hole so what should I do to tighten that down without losing too much flexability?
If I were to leave it, how could I render a link or build a route such that I could link users externally? This doesn't work (of course):
<a href="@item.Location" target="_self">@item.Title</a>
Upvotes: 3
Views: 3538
Reputation: 486
Append protocol before @item.URL
like this:
<a href="http://@item.URL" target="_blank">@Html.DisplayFor(modelItem => item.Title)</a>
Upvotes: 7