Anchor tag helper to open a view in a new tab window

Using the tag binding helper , how can we open ASP.NET Core MVC Viewin a new tab in the browser window. I tried the following, but first he complained that the attribute targetmust have an attribute href. But, as we know, we cannot use the href attribute with the attribute asp-actionin MVC Core; otherwise, we get the error shown below. NOTE : I saw a few sentences like <him, but they are not tag related:

<a asp-action="testAction" href="#" target="_blank">Click Here</a>

Error:

InvalidOperationException: cannot override the 'href' attribute for, The user with the specified "href" should not have attributes starting with "asp-route-" or "asp-action", "asp-controller", "asp-area", "asp-route", "asp-protocol", "asp-host" or the asp-fragment attribute.

+4
source share
2 answers

I'm not sure if you are asking a question or want to share your results?

@Mohamed Rozza , Visual Studio target href, , . Visual Studio.

, / , :

<a href="@Url.Action("testAction","Home")" target="_blank">Click Here</a>

, , . ?

:

  • 100% ?
  • ?
  • -, ?
  • ?
  • Visual Studio, ?

, .

  • , VS
  • , Url.Action()

/. - -, ... , !

Microsoft , href, !

, , , 100% - (, ), , , , .

+3

Razor Tag Helper,

@addTagHelper "*, Microsoft.AspNet.Mvc.TagHelpers"

_ViewImports.cshtml, "". , . Razor . , .

-1

Source: https://habr.com/ru/post/1667520/


All Articles