fullstackproltd / AspNetCoreSpa

Asp.Net 7.0 & Angular 15 SPA Fullstack application with plenty of examples. Live demo:
https://aspnetcorespa.fullstackpro.co.uk
MIT License
1.48k stars 465 forks source link

new AspNetCoreSpa Project #200

Closed sajidali2444 closed 6 years ago

sajidali2444 commented 6 years ago

i just downloaded restore everything but proejct not running thorwing errors on port proxy error. not working on localhost:26853 and localhost:5000?

An unhandled exception occurred while processing the request. CurlException: Couldn't connect to server System.Net.Http.CurlHandler.ThrowIfCURLEError(CURLcode error)

HttpRequestException: An error occurred while sending the request. System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

HttpRequestException: Failed to proxy the request to http://localhost:4200/, because the request to the proxy target failed. Check that the proxy target server is running and accepting requests to http://localhost:4200/.

The underlying exception message was 'An error occurred while sending the request.'.Check the InnerException for more details. Microsoft.AspNetCore.SpaServices.Extensions.Proxy.SpaProxy+d__4.MoveNext() System.Net.Http.HttpRequestException: Failed to proxy the request to http://localhost:4200/favicon.ico, because the request to the proxy target failed. Check that the proxy target server is running and accepting requests to http://localhost:4200/.

lukasvencalek commented 6 years ago

I had the same issue with the proxy approach. To make it work comment line spa.UseProxyToSpaDevelopmentServer("http://localhost:4200"); in startup.cs and use spa.UseAngularCliServer(npmScript: "start");

asadsahi commented 6 years ago

@sajidali2444 angular cli process takes some time to build the project. If you are running npm start in command line, wait for it to finish before you start the .net project using F5 or similar. See if this fixes your issue.

On the other hand you can change as per @Vencalekl 's instructions to run with single F5 style to run the project.

Closing it for now as there are couple of way to run the projects for now. Hope that is ok.

sfrjrs commented 6 years ago

@Vencalekl @asadsahi - Thank you. The above fix worked.

sajidali2444 commented 6 years ago

Thanks @Vencalekl , @asadsahi its working now.

pratishthap commented 6 years ago

Hi. I am getting the same error. Only when i hit refresh on browser does that error go away.Any ideas how to fix it.I am using VS 2017

aaroncalderon commented 6 years ago

@sajidali2444 I was having the same problem, turns out that I was not starting the npm server with npm start on the ClientApp server.

fhs2020 commented 5 years ago

@sajidali2444 I was having the same problem, turns out that I was not starting the npm server with npm start on the ClientApp server.

This also worked for me! Thanks!

eliezer2501 commented 3 years ago

@sajidali2444 this also worked for me thank you

yangs2016 commented 1 year ago

I am having same problem - I was able to run "npm start" manully under ClientApp folder and started my React app successfully. But when I tried to run the AspNet Core project, using ...spa.UseReactDevelopmentServer(npmScript: "start") in program startup, I got error like this "HttpRequestException: Failed to proxy the request to http://localhost:49812/, because the request to the proxy target failed. Check that the proxy target server is running and accepting requests to http://localhost:49812/."

Question, where did this dynamic port number come from even I specified the react to start on port 3000 (default)?

4/13/23: Problem solved by making these 2 changes: 1) added this line "ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.SpaProxy" to the launchSettings.json file, below the line " "ASPNETCORE_ENVIRONMENT": "Development" (without this line, you will continue to get error like "HttpRequestException: Failed to proxy the request to http://localhost:61505/, because the request to the proxy target failed. Check that the proxy target server is running and accepting requests to http://localhost:61505/.) 2) added this to project properties page: <SpaProxyServerUrl>https://localhost:3000</SpaProxyServerUrl>. Without this, you will get a Http 500 error: "This page isn’t working right nowlocalhost can't currently handle this request. HTTP ERROR 500"