emonney / QuickApp

ASP.NET Core / Angular startup project template with complete login, user and role management. Plus other useful services for Quick Application Development
https://www.ebenmonney.com/quickapp
MIT License
1.26k stars 594 forks source link

enable asp.net web api session when working with angular5 on localhost #99

Closed noah2233 closed 5 years ago

noah2233 commented 6 years ago

In production mode I have the angular 5 client and the web api on the same site so I have no problem with the session but in development mode my angular 5 is hosted on localhost:4200 which reset the session on each call to a service. I can host the angular 5 and the web api on the same host on development mode but it means I have to do ng build all the time(which will have a big overhead). Any ideas? Should I use the session?

liphis commented 6 years ago

Do you really think that posting the same question on multiple repositories (unrelated to your question btw) and ignoring the replies you get will magickly code for you?

Mynken commented 6 years ago

In production mode I have the angular 5 client and the web api on the same site so I have no problem with the session but in development mode my angular 5 is hosted on localhost:4200 which reset the session on each call to a service. I can host the angular 5 and the web api on the same host on development mode but it means I have to do ng build all the time(which will have a big overhead). Any ideas? Should I use the session?

Hi, @noah2233, Open the Startup.cs and at the end of this file in code blick "if (env.IsDevelopment())" you can find this info: //spa.UseProxyToSpaDevelopmentServer("http://localhost:4200"); // Use this instead to use the angular cli server Unncoment this and change port to port which you need.

emonney commented 5 years ago

@Mynken approach should work fine for your situation. The angular part is made with angular cli. You can move it out of the project and threat it as you would any other angular cli project