Coder Social home page Coder Social logo

Comments (7)

rstropek avatar rstropek commented on September 18, 2024 1

BTW - added a comment to readme that you have to start the API project before running the rest of the sample.

from starshiptraveler.

muneebakhter avatar muneebakhter commented on September 18, 2024 1

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.

rstropek avatar rstropek commented on September 18, 2024

Did you also start the API project? Contains a Web API that the client consumes.

from starshiptraveler.

muneebakhter avatar muneebakhter commented on September 18, 2024

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.

rstropek avatar rstropek commented on September 18, 2024

Hmm, interesting. The API allows CORS (

services.AddCors(o => o.AddPolicy("AllowEverything", builder =>
). What did you have to change to make it work?

from starshiptraveler.

muneebakhter avatar muneebakhter commented on September 18, 2024

Its not the API, that works fine. It's from the StarshipTraveler.Client somehow.

Steps to recreate problem:

  1. Git clone Repo
  2. Open Visual Studio 2019 Preview (with .Net 3.1 SDK and blazor templates) on Start folder solution
  3. Modify Startup Projects to have both StarshipTraveler.Api and StarshipTraveler.Client
  4. Copy TicketList.razor from Assets 010 to StarshipTraveler.Components Page
  5. 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.

rstropek avatar rstropek commented on September 18, 2024

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 photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.