ASP.NET CORE MVC: `asp-action` doesn't create the `href` attribute

Andrey Bushman

Visual Studio 2017 (v15.4.4)
ASP.NET CORE MVC

Code source:

@model Razor.Models.GuestResponse
@{ 
    Layout = null;
}

<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width"/>
    <title>Index</title>
</head>
<body>
    @ViewBag.Greeting World (from the view)
    <p>We're going to have an excuting party.<br/>
    (To do: sell it better. Add pictures or something.)</p>
    <a asp-action="RsvpForm">RSVP Now.</a>
</body>
</html>

But asp-action attribute doesn't create the href attribute. I get such result in Google Chrome:

<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width"/>
    <title>Index</title>
<script type="text/javascript" src="http://gc.kis.v2.scr.kaspersky-labs.com/50E639F5-BFDC-EB4A-B0CB-8404EE08E366/main.js" charset="UTF-8"></script><link rel="stylesheet" crossorigin="anonymous" href="http://gc.kis.v2.scr.kaspersky-labs.com/663E80EE4048-BC0B-A4BE-CDFB-5F936E05/abn/main.css"/></head>
<body>
    Good Afternoon World (from the view)
    <p>We're going to have an excuting party.<br/>
    (To do: sell it better. Add pictures or something.)</p>
    <a asp-action="RsvpForm">RSVP Now.</a>
</body>
</html>

What can be the reason for such result?

topcool

Use these two lines of code above your View :

@model Razor.Models.GuestResponse

@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@addTagHelper *, YourProjetcName

If the problem did not resolve after adding these codes restart visual studio.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Invoke ASP.Net Core MVC controller action with parameter doesn't work

Action doesn't come to a head in Asp.Net MVC 4

ASP.NET Core Action Filter Doesn't Get Called

Uploader in Create action - Asp.net MVC

ASP.NET core "create" action

Why is my ASP.NET Core MVC page trying to override the 'action' attribute for <form>?

asp-action in ASP.NET Core 3.1 doesn't work with endpoint routing

Asp.Net MVC using Tilde in href attribute for relative paths

How can i configure attribute based routing on startup file instead of using attribute on controller action in asp.net core mvc

How to create two objects with one action in ASP.NET Core MVC

ActionName Attribute & UrlHelper.Action Method in ASP.NET MVC

How to generate URL for the action with attribute routing in Asp.Net MVC

What is the risk of form action attribute in asp net mvc?

How to get custom attribute name for action in asp.net core?

Tow way for call a action in asp.net mvc with route attribute - Routing In asp.net mvc

ASP.NET Core (MVC): Can't get to the Login HttpPost action in controller

Update model with TryUpdateModel in ASP.NET MVC Core Web API and Entity Framework Core doesn't work

ASP.NET MVC Why doesn't this post action get called from the view?

Why doesn't $.get Url.Action reach ASP.NET MVC async Controller?

url.action doesn't generate url in asp.net mvc

Valid RegEx doesn't work with ASP.Net MVC RegularExpression attribute

ASP.NET MVC Remote Attribute doesn't work in bootstrap modal

Changing default action doesn't work for ASP.NET Core 2

ASP.NET Core redirect from POST action to url doesn't work

Custom Authorization attribute doesn't allow authorize in asp.net core 3

Edit action with Dependency Injection ASP.Net Core MVC

404 error for any action with asp.net core MVC

ASP.NET Core MVC equivalent of Start Action Specific Page

Asp.net core MVC make action optional in routing