dotnet / dotnet/aspnetcore

GetUriByAction without HttpContext cannot be used normally.

Open
#54,054 0 comments 0 reactions 0 assignees View on GitHub
area-mvc
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 6h
Merged PRs (30d)
290

Description

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Describe the bug

```
test1

test2

Details

```

The code above can build/run well, but not works in the page.

![image](https://github.com/dotnet/aspnetcore/assets/23260922/74a043c1-7aa5-48da-9243-de4f4f096639)

### Expected Behavior

the test1 and test2 should also be a link.

![image](https://github.com/dotnet/aspnetcore/assets/23260922/56b0d2e2-a9a0-4f98-86a7-7bb4759b35e8)

### Steps To Reproduce

1. Create a ASP.NET CORE Razor Page Project
2. Find the index.html and paste the code below.
```
@page
@inject Microsoft.AspNetCore.Routing.LinkGenerator LinkGenerator
@using Microsoft.AspNetCore.Routing
@model IndexModel
@{
ViewData["Title"] = "Home page";
}

test1

test2

Details
```

### Exceptions (if any)

N/A

### .NET Version

.NET 6/7/8

### Anything else?

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.