Comments (7)
BTW - added a comment to readme that you have to start the API project before running the rest of the sample.
from starshiptraveler.
I did start the API too, I think there might need to be some IP configuration local settings I need to twiddle with.. Great speech btw, I just downloaded and ran it after watching the speech.
from starshiptraveler.
Did you also start the API project? Contains a Web API that the client consumes.
from starshiptraveler.
So I found the problem and it was CORS policy.
The localhost that was running the API and the Client app were on two different localhost ports, which in WebAssembly might as well be a completely different domain.
from starshiptraveler.
Hmm, interesting. The API allows CORS (
). What did you have to change to make it work?from starshiptraveler.
Its not the API, that works fine. It's from the StarshipTraveler.Client somehow.
Steps to recreate problem:
- Git clone Repo
- Open Visual Studio 2019 Preview (with .Net 3.1 SDK and blazor templates) on Start folder solution
- Modify Startup Projects to have both StarshipTraveler.Api and StarshipTraveler.Client
- Copy TicketList.razor from Assets 010 to StarshipTraveler.Components Page
- Press F5 (it's stuck on loading)
Api runs on a different port for me (localhost:63655) and Client (localhost:63656), so I changed the App Url to port 5000 / 5001 and followed https://developer.okta.com/blog/2018/10/15/blazor-and-web-assembly Still no help.
I used the Network Tab to see if the request made it through and it did. Even Fiddler picked it up. So I thought maybe the logic for tickets is bad. I hard-coded the Ticket and it showed. So it's definitely the http.GetAsync function. I even tried just printing out the JSON string directly and it hung.
I tried function proxies that mimic the results and set CORS on it (ie. https://startickets.azurewebsites.net/api/tickets) following Dan Roth's Advice (https://github.com/aspnet/AspNetCore/issues/15300)) and still nothing.
So, I was left with the nuclear option. Create a Blazor App from scratch and copy paste the active code snippets.
P.S. I think the reason you used GetAsync and deserialized it instead of GetJsonAsync<Ticket[]> is because the razor component class doesn't use the same HttpClient as the one in blazor. I need a lot of help figuring all this out, and I left Angular for a while when they were going through their component phase.
from starshiptraveler.
Hi @muneebakhter!
Thank you very much for taking the time to write such a detailed problem description. I could reproduce your problem. I always run the API as a console app and avoid running it in IIS. If I switch to IIS (which is the default after cloning the repo), I can reproduce your problems.
I added a corresponding tip to the readme file so that other people trying the sample know that they should switch to console app instead of IIS.
Greetings,
Rainer.
from starshiptraveler.
Related Issues (2)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from starshiptraveler.