How to properly encode links to external URL in MVC Razor

前端 未结 5 1790
Happy的楠姐
Happy的楠姐 2021-01-03 21:26

This view suppose to show a list of hyperlinks, each pointing to an external URL. The goal is for the user to click one of these links and have their browser open a new tab

5条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-03 21:54

    You don't need to use @Html.ActionLink for that. Just use a plain A tag:

    SomeSite
    

    Html.ActionLink is specifically for generating links to actions defined in MVC controllers, in the same app. Since you're linking to an absolute URL, you don't need any of the functionality that Html.ActionLink provides.

提交回复
热议问题