gpt4 book ai didi

asp.net-mvc - ASP.NET 核心 MVC : `asp-action` doesn't create the `href` attribute

转载 作者:行者123 更新时间:2023-12-04 12:46:11 24 4
gpt4 key购买 nike

Visual Studio 2017 (v15.4.4)
ASP.NET 核心 MVC

代码来源:

@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>

但是 asp-action 属性不会创建 href 属性。我在 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>

造成这种结果的原因是什么?

最佳答案

在您的 View 上方使用这两行代码:

@model Razor.Models.GuestResponse

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

如果添加这些代码后问题没有解决,请重新启动 visual studio。

关于asp.net-mvc - ASP.NET 核心 MVC : `asp-action` doesn't create the `href` attribute,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47369650/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com