Last post Feb 11, 2019 10:08 PM by mgebhard
Feb 11, 2019 07:49 PM|dbqasp|LINK
I am passing the following ViewBag from controller to view
ViewBag.Links = "<a href='www.google.com' target='_blank'>Google</a>. <a href='www.microsoft.com' target='_blank'>Microsoft</a>";
In view I have the following
When this view is rendered, it displays Google and Microsoft. However, the url it points to is relative, i.e.
which opens a tab with
What should I do so that the link opens?
Feb 11, 2019 10:08 PM|mgebhard|LINK
You're missing the https. The browser thinks the link is relative to the site.
ViewBag.Links = "<a href='https://www.google.com' target='_blank'>Google</a>. <a href='https://www.microsoft.com' target='_blank'>Microsoft</a>";
I would pass the a list of URLs and have the View wrap the URLs in HTML as that's what View and HTML helpers are designed to do.