Blazor: Query Parameter (ReturnUrl) not received when using InteractiveServer mode after authorization redirection
- 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**:
When using `@rendermode InteractiveServer` in a Blazor page, after a user is redirected to the login page (due to the `[Authorize]` attribute) and the `ReturnUrl` is passed in the query, the `ReturnUrl` parameter is not correctly received when exiting `InteractiveServer` mode.
### **Steps to Reproduce**:
1. Create a Blazor page with `@rendermode InteractiveServer` and the `[Authorize]` attribute.
2. Attempt to access this page while the user is not logged in.
3. The user is redirected to the login page with the `ReturnUrl` query parameter in the URL.
4. On the login page, the `ReturnUrl` query parameter is not correctly received when `@rendermode InteractiveServer` is used.
5. If `@rendermode InteractiveServer` is removed from the login page, the `ReturnUrl` parameter is correctly received.

### **Expected Behavior**:
The `ReturnUrl` (or any other query parameter) should be correctly passed and handled on the login page, regardless of whether `@rendermode InteractiveServer` is used.
### **Actual Behavior**:
The `ReturnUrl` query parameter is not received when the login page uses `@rendermode InteractiveServer`. Removing `@rendermode InteractiveServer` from the login page resolves the issue.
### **Workaround**:
Remove `@rendermode InteractiveServer` from the login page to properly receive query parameters.
### .NET Version
9.0.101
### **Home Page**:
```razor
@page "/"
@rendermode InteractiveServer
Home Page
```
### **Login Page**:
```razor
@page "/account/login"
@rendermode InteractiveServer
Login Page
ReturnUrl: @ReturnUrl
@code {
[SupplyParameterFromQuery] public string? ReturnUrl { get; set; }
}
```
### **Weather Page**:
```razor
@page "/weather"
@attribute [Authorize]
Weather Page
```
### **Update**:
A repro project is available here: [Blazor-Auth-Redirect-Issue](https://github.com/MAghazade/Blazor-Auth-Redirect-Issue)
Contributor guide
Assessment
This issue has not been assessed yet.