简体   繁体   English

在 Visual Studio 中链接网页

[英]Linking webpages in visual studio

I have been trying to link other webpages using我一直在尝试使用链接其他网页

<a href="~/Pages/a.cshtml"><li>About</li></a>

but when I try it it shows me the following error:但是当我尝试它时,它向我显示以下错误:

This localhost page can't be found No webpage was found for the web address: https://localhost:5001/Pages/a.cshtml HTTP ERROR 404找不到此本地主机页面没有找到 web 地址的网页:https://localhost:5001/Pages/a.cshtml HTTP 错误

I'm using visual studio on mac version 8.6.6 I'm using ASP.NET我在 Mac 版本 8.6.6 上使用 Visual Studio 我正在使用 ASP.NET

From your anchor tag link url ~/Pages/a.cshtml it seems that you are working with MVC project.从您的锚标记链接 url ~/Pages/a.cshtml 看来您正在使用 MVC 项目。

In order to navigate (or link) pages you need something like this:为了导航(或链接)页面,您需要以下内容:

<a href="@Url.Action("YourLandingPageName","YourControllerName">About</a>

You don't need to add the.cshtml.您不需要添加.cshtml。

If you are using ASP.NET 3.1 you can use the Anchor Tag Helper asp-page to go to other pages.如果您使用 ASP.NET 3.1,您可以使用 Anchor Tag Helper asp-page to go to other pages。

Below is a peice of code that works on one of my Razor Page websites:下面是在我的 Razor 页面网站上运行的一段代码:

<td><a asp-page="About">About</a></td>

So in your case just make sure to include the correct path to the page因此,在您的情况下,只需确保包含页面的正确路径

Check out this link for more information on Tag Helpers in ASP.NET.查看此链接以获取有关 ASP.NET 中标签助手的更多信息。 Pretty cool stuff.很酷的东西。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM