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

Not calling RestAPI #403

Closed
graylobo opened this issue May 17, 2020 · 5 comments
Closed

Not calling RestAPI #403

graylobo opened this issue May 17, 2020 · 5 comments
Labels

Comments

@graylobo
Copy link

  • Version: 8.31.2
  • Target:

20200517_203428

I'm trying to call RestAPI data, using httpclient library in nuget.

20200517_205822

20200517_213450

It works fine in the browser, but if I build it with electron.net in the same environment and click it,
there is no response.
github code link is below
https://github.com/graylobo/BlazorTron
Can I fix this issue? thanks in advance

@graylobo graylobo added the bug label May 17, 2020
@konstantingross
Copy link
Contributor

Your ElectronNET port does not match the port of the RestAPI call.

Add following line to your Program.cs:
webBuilder.UseStartup();
webBuilder.UseUrls("http://*:8001"); //e.g. 8001

RestAPI.razor:
Students = await http.GetJsonAsync<List>("http://localhost:8001/api/students");

image

@graylobo
Copy link
Author

graylobo commented May 18, 2020

Thank you. It works well thanks to your advice.
However, How can i get bact to the main page (_Host.cshtml) if i in new page? (e.g. json link page)
20200518_112120

20200518_112653

I try to new MenuItem { Label = "Home", Accelerator = "CmdOrCtrl+H",Role = MenuRole.undo}``
but it doesn't work.

And if I want to debugging electron.net, is this answer is the best way to do it yet?
#298
Is it normal for a breakpoint not to be recognized at electron.net runtime even if a breakpoint is specified?

@konstantingross
Copy link
Contributor

Try this but I don't know if this is best practice:
new MenuItem { Label = "Home", Click = () => Electron.WindowManager.BrowserWindows.First().LoadURL("http://localhost:8001/")

@GregorBiswanger
Copy link
Member

The safest way would be:
new MenuItem { Label = "Home", Click = () => Electron.WindowManager.BrowserWindows.First().LoadURL($"http://localhost:{BridgeSettings.WebPort}/")

Did we solve your problem?

@graylobo
Copy link
Author

Yes, it works perfect. Thanks a bunch!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants