dotnet-presentations / blazor-workshop

Blazor workshop
https://aka.ms/blazorworkshop
MIT License
3.47k stars 1.54k forks source link

Using Visual studio code #299

Open eliassal opened 3 years ago

eliassal commented 3 years ago

This tutorial seems very useful to learn blazor. I use VSC and don't have VS. In chapter 01-components-and-layout, a note indicates The BlazingPizza.Server project should be set as the startup project. I am not sure how to do this in VSC, but on command line, I switch to BlazingPizza.Server directory, issue dotnet run everything compiles and get Edge fired with the url https://localhost:5001/ (looking at this project properties we have

"applicationUrl": "https://localhost:5001;http://localhost:5000")

I I update BlazingPizza.Client as per tutroial, I get everything correct. When I type in the browser the client URL http://localhost:8080, it does not work. Can you please indicate how this works and where is the link between client and server? I understand that to access the app we should use the client, NO? Thanks in advance

D3KOD3R commented 3 years ago

change the application url to http://localhost:5000" the server url to http://localhost:5001"

the server needs to be running preferably before you run the application client up.

client 5000 server 5001

yes you need to use the client to access the application.

once you have changed the application url's to the above.

type in the browser the url for the client.

also set multiple startup and set the server to start up aswell. do this by right clicking on the sln file

Capture

eliassal commented 3 years ago

Thanks, I will do. However, as I indcated, I use visual studio code, how can I achieve setting multi startup and prioritize them? Thanks again

eliassal commented 3 years ago

But D3, still I need a response please, how I was accessing the server url and updates I do in client were reflected and worked fine

eliassal commented 3 years ago

In the client project, I do dotnet run but it fails, how I can run the client? So the question now is How do I run the client application? In the launch.json of the root app it is indicated "type": "edge", "request": "launch", "name": "Launch Edge against localhost", "url": "http://localhost:8080", "webRoot": "${workspaceFolder}\BlazingPizza.Server" So should I change this or where I change the url for the client? Thanks

eliassal commented 3 years ago

I changed the webRoot value to "url": "http://localhost:5000", "webRoot": "${workspaceFolder}\BlazingPizza.Client" when I hit run in VSC, I get a very strange error PizzaClient

D3KOD3R commented 3 years ago

Oh sorry. Um not sure if it will work in vs code

Get Outlook for Androidhttps://aka.ms/ghei36


From: eliassal notifications@github.com Sent: Monday, January 25, 2021 8:38:12 PM To: dotnet-presentations/blazor-workshop blazor-workshop@noreply.github.com Cc: D3k0D3R mitchelljohnstorrie@hotmail.com; Comment comment@noreply.github.com Subject: Re: [dotnet-presentations/blazor-workshop] Using Visual studio code (#299)

I changed the webRoot value to "url": "http://localhost:5000", "webRoot": "${workspaceFolder}\BlazingPizza.Client" when I hit run in VSC, I get a very strange error [PizzaClient]https://user-images.githubusercontent.com/8447864/105694911-c3d42b80-5f01-11eb-8fd1-695d7d8ab423.jpg

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/dotnet-presentations/blazor-workshop/issues/299#issuecomment-766722060, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ASLEIYFS66FBKYU3WXKLZFTS3VCZJANCNFSM4WM7FKXQ.

eliassal commented 3 years ago

even when I revert bakc to "webRoot": "${workspaceFolder}\BlazingPizza.Server" I get the same error. Anyway, lest imagine I have VS, how the link between the client and server works, where is the connection done is done. If I understand how the link works maybe I can find a solution. It is not possible to use DOTNET RUN with the client project

eliassal commented 3 years ago

As I said, whe I do DOTNET RUN inside the server project from powershell command line, it runs correctly and can access all functions BUT what IS STRANGE is the updates in client are reflected whereas I am accessing the server, so my question again how this can happen, where is the link?

PizzaServer_DotNetRun

PizzaServer_DotNetRun_002

RonnyRusten commented 3 years ago

Look in the .sln and .csproj-files. I THINK the links are in these files, but they might as well be somewhere else (I actually don't know, but saw some connections there...). I recomend VS 2019 Community Edition if you can't get VS Code to work...

lohithgn commented 3 years ago

This tutorial seems very useful to learn blazor. I use VSC and don't have VS. In chapter 01-components-and-layout, a note indicates The BlazingPizza.Server project should be set as the startup project. I am not sure how to do this in VSC, but on command line, I switch to BlazingPizza.Server directory, issue dotnet run everything compiles and get Edge fired with the url https://localhost:5001/ (looking at this project properties we have

"applicationUrl": "https://localhost:5001;http://localhost:5000")

I I update BlazingPizza.Client as per tutroial, I get everything correct. When I type in the browser the client URL http://localhost:8080, it does not work. Can you please indicate how this works and where is the link between client and server? I understand that to access the app we should use the client, NO? Thanks in advance

Hi. Although the front end is Blazor WebAssembly - it is being served from a Web Server. Blazor WebAssembly can be thought of as a Static Site App. But you need a server to serve the web assets. In this demo we create a ASP.NET MVC Server and we use this server to serve the Blazor Static Site App. Plus the Server is also used to create the APIs required by the Blazor WebAssembly App.

When you navigate to https://localhost:5001 - this serves the client app (i.e. blazor webassembly app). the client app runs in your browser & makes an api call on the same domain. If you look at OrderClient class it is making a request to "orders" endpoint. When the call is made the complete endpoint will be https://localhost:5001/orders ... This is how the demo is working and architected.

Hope this helps.