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

navigation in blazor uri helper after http call is navigating to same page with "?" #1799

Closed
pmaheshgupta opened this Issue Mar 19, 2019 · 3 comments

Comments

Projects
None yet
3 participants
@pmaheshgupta
Copy link

pmaheshgupta commented Mar 19, 2019

Hi all,

I am trying to navigate to another page in onclick event after a http service call, but i am unable to navigate, instead it is loading the same page with "?" appended at the end.

My onclick event is as follows

protected async Task checkpnr()
    {
        string uri = baseurl + "api/pnr/" + pnr + "/check";     
       string isvalidpnr = await Http.GetStringAsync(uri);
        if (isvalidpnr == "true")
        {
            await JsRuntime.InvokeAsync<bool>("setpnr", pnr);
            UriHelper.NavigateTo("/selectpassenger");          
        }
        else
        {
            showerror = true;
        }
    }

in the output I am getting

Navigated to http://localhost:50506/?

[Violation] 'setTimeout' handler took 178ms      mono.js

In the above code if i remove service call and assign a static value to isvalidpnr, I am able to navigate to the mentioned page.

please let me know what the issue is and how to solve it.

@TomaszGrzmilas

This comment has been minimized.

Copy link

TomaszGrzmilas commented Mar 21, 2019

Hi

Did you bound your function to a button in form ?
If so, try change button type
from <button type="submit" ...
to <button type="button" ...

Hope that helps.

Br.

@pmaheshgupta

This comment has been minimized.

Copy link
Author

pmaheshgupta commented Mar 22, 2019

yes it helped.. thanks a lot.. but the behavior is strange,with type="submit" it sometimes works correctly and the other time it doesn't.

@SteveSandersonMS

This comment has been minimized.

Copy link
Member

SteveSandersonMS commented Mar 25, 2019

Oh I see - you were submitting the form. Since you don't want to do that, be sure to use type=button.

Also please note that we no longer accept issues posted to this repo. Instead, issues relating to Blazor or Razor Components should be posted at https://github.com/aspnet/aspnetcore

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.