Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NavigationException raised when using NavigationManager.NavigateTo upon form post in SSR #50478

Closed
1 task done
blissvalley opened this issue Sep 1, 2023 · 9 comments
Closed
1 task done
Labels
area-blazor Includes: Blazor, Razor Components ✔️ Resolution: Answered Resolved because the question asked by the original author has been answered. question Status: Resolved

Comments

@blissvalley
Copy link

blissvalley commented Sep 1, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

NavigationException raised when using NavigationManager.NavigateTo upon form post in server-side rendering

Expected Behavior

redirect page to destination

Steps To Reproduce

@page "/admin_login"
@attribute [StreamRendering(true)]

@using Models
@inject NavigationManager Navigation

<h3>AdminLogin</h3>

<EditForm Model="loginRequest" OnValidSubmit="ProcessLogin" FormName="AdminLoginForm">
    <div class="form-group">
        <label for="password" class="form-label">Password:</label>
        <InputText id="password" class="form-control" @bind-Value="@loginRequest.Password" type="password" />
    </div>
    <div class="mb-2">
        <button type="submit" class="btn btn-primary">Login</button>
    </div>

</EditForm>

@if (errorMessage != null)
{
    <div class="alert alert-danger" role="alert">
        @errorMessage
    </div>
}

@code {

    [SupplyParameterFromForm]
    private LoginRequest loginRequest { get; set; } = new();

    private string? errorMessage { get; set; } = null;

    private void ProcessLogin()
    {

        if (loginRequest.Password == "123")
        {
            Navigation.NavigateTo("/admin"); //Exception Raised
        }
        else
        {
            errorMessage = "Invalid password";
        }
    }

}

Exceptions (if any)

No response

.NET Version

8.0.100-preview.7.23376.3

Anything else?

No response

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-blazor Includes: Blazor, Razor Components label Sep 1, 2023
@marinasundstrom
Copy link

This seems like an issue that I have encountered.

The NavigationManager not being for SSR.

From what I heard it should be fixed. Perhaps not released yet.

@marinasundstrom
Copy link

marinasundstrom commented Sep 1, 2023

Duplicate? #49670

Although, I can't reproduce it with the specified SDK version.

Not with my own code, or with the code provided.

@marinasundstrom
Copy link

This one seems more likely: #50260

@mkArtakMSFT
Copy link
Member

Thanks for contacting us. Does this exception result in an error in application or does it simply go away after you Continue debugging (F5) ?

@mkArtakMSFT mkArtakMSFT added the Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. label Sep 11, 2023
@ghost
Copy link

ghost commented Sep 11, 2023

Hi @blissvalley. We have added the "Needs: Author Feedback" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

@danroth27
Copy link
Member

I'm unable to reproduce this exception with .NET 8 RC1.

@danroth27 danroth27 added the Needs: Repro Indicates that the team needs a repro project to continue the investigation on this issue label Sep 11, 2023
@ghost
Copy link

ghost commented Sep 11, 2023

Thank you for filing this issue. In order for us to investigate this issue, please provide a minimal repro project that illustrates the problem without unnecessary code. Please share with us in a public GitHub repo because we cannot open ZIP attachments, and don't include any confidential content.

@blissvalley
Copy link
Author

Thanks for contacting us. Does this exception result in an error in application or does it simply go away after you Continue debugging (F5) ?

When continue using F5, the program continue and go to destination page successfully.

@ghost ghost added Needs: Attention 👋 This issue needs the attention of a contributor, typically because the OP has provided an update. and removed Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. labels Sep 12, 2023
@javiercn
Copy link
Member

@blissvalley thanks for the additional details.

That exception is launched and caught internally by the framework, the behavior is by design. You can avoid pausing on it if you turn off first chance exceptions

@javiercn javiercn added question ✔️ Resolution: Answered Resolved because the question asked by the original author has been answered. and removed Needs: Attention 👋 This issue needs the attention of a contributor, typically because the OP has provided an update. Needs: Repro Indicates that the team needs a repro project to continue the investigation on this issue labels Sep 12, 2023
@ghost ghost added the Status: Resolved label Sep 12, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Oct 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Includes: Blazor, Razor Components ✔️ Resolution: Answered Resolved because the question asked by the original author has been answered. question Status: Resolved
Projects
None yet
Development

No branches or pull requests

5 participants