Andrey Bushman
Andrey Bushman

Reputation: 12486

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

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?

Upvotes: 3

Views: 1681

Answers (1)

topcool
topcool

Reputation: 2720

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.

Upvotes: 5

Related Questions