locked
relative path to ASP.NET Core Razor page hyperlink RRS feed

  • Question

  • I am a novice with ASP.NET Core Razor pages.

    What is the correct syntax for including a hyperlink to another Razor page found within the same folder? 

    I can't seem to find the right path.
    Friday, September 11, 2020 4:50 PM

All replies

  • You can manually do it, because the razor helper tags are suspect. 

    it's equates to Pages/Article/ArticleIndex 
    @page
    @model IndexModel
    @{
        ViewData["Title"] = "Index";
    }
    
    <!DOCTYPE html>
    
    <html>
    <head>
        <meta name="viewport" content="width=device-width" />
        <title>Articles</title>
    </head>
    <body>
    <h1>Articles</h1>
    
    <form>
    
        <br /><br />
        <h5>Authors select Articles</h5>
        <br />
        <table border="1" cellpadding="10">
            <tr>
                <th>First Name</th>
                <th>Last Name</th>
                <th colspan="4">Actions</th>
            </tr>
            @foreach (var item in Model.AuthorVM.Authors)
            {
                <tr>
                    <td>@item.FirstName</td>
                    <td>@item.LastName</td>
                    <td>
                        <a href="/Article/ArticleIndex?id=@item.AuthorID">Select</a>
                    </td>
                </tr>
            }
        </table>
    </form>
    </body>
    </html>
    
    
    

    https://forums.asp.net/

    ASP.NET has forums.


    Friday, September 11, 2020 6:21 PM