简体   繁体   中英

How to use a routing url in the anchor tag helper?

I am using Razor Pages and have a file "Author.cshtml" inside a catalog /Pages/Author/ with the following content:

@page "/Author"
@model MyApplication.Web.Pages.Author.AuthorModel

Lorem ipsum

I set routing as "/Author". The following link doesn't work:

<a asp-page="/Author">Author</a>

I need to write:

<a asp-page="/Author/Author">Author</a>

But I want to use: "/Author", not "/Author/Author" in the anchor tag helper, what should I do?

try

<a href="" @onclick="NavigatetoNextComponent">Click here</a>  
  
@code {  
    void NavigatetoNextComponent()  
    {  
         NavigationManager.NavigateTo("/Author", true);
    }  
}  

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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