1

A very easy question. I am just getting started with MVC. I have external URL's stored in my database. The following line of markup renders the link www.google.com as localhost/Home/www.google.com

<a href="@item.URL" target="_blank">@Html.DisplayFor(modelItem => item.Title)</a>

Where am I going wrong

Cheers

1 Answer 1

1

It doesn't actually render that way but since you have no protocol http:// or http:// in front of it.. it thinks it is a path based on your current page. So - append a protocol in front of it

Sign up to request clarification or add additional context in comments.

1 Comment

<a href="http://@item.URL" target="_blank">@Html.DisplayFor(modelItem => item.Title)</a> worked :) , As did adding http:// to the database URLs Cheers

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.