microsoft / dotnet

This repo is the official home of .NET on GitHub. It's a great starting point to find many .NET OSS projects from Microsoft and the community, including many that are part of the .NET Foundation.
https://devblogs.microsoft.com/dotnet/
MIT License
14.35k stars 2.21k forks source link

ASP .NET Core 2.1 React Template can't talk to controllers? #790

Open je-can-code opened 6 years ago

je-can-code commented 6 years ago

I dropped this on stackoverflow, but for maximum visibility, I'll drop it here, too:

Perhaps this is my lack of knowledge in how this works (I'm an intern trying to help the team convert from 2.0 >> 2.1 template), but I have am having issues with this new ASP.NET Core 2.1 React Template, and publishing it on our IIS Server.

As a proof-of-concept, I just created a new project out of the box, add an easy /api/weather call, published as Release (read somewhere that was important), dropped it on the company's IIS dev server... and assumed that when I pointed the web app at the contents of the folder, it would just work (like it did with ASP.NET Core 2.0). However, it complains about being unable to run/install via npm when visiting the site... but DOES work if you instead point it at /build folder.

So great, we use the IIS Manager to point it at the /build folder, the site loads the static pages and such... but loses the capability to access the APIs within the controllers (such as /api/sampledata/weather) via fetch/axios. This is causing problems with other things (details unnecessary for this post), and so I was hoping someone else might have some insight into why the 2.1 template fails to work while the 2.0 did?

Oh, and I did update the dev machine we have from 2.0 >> 2.1, so everyone is running the same .NET Core version.

Any ideas? If there is more data necessary, please ask, happy to volunteer just about anything that isn't sensitive data.

For reference to what that error was I got:

TypeError: Cannot read property 'get' of undefined at errorHandler (C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:205:18) at C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js:83:20 at cb (C:\Program Files\nodejs\node_modules\npm\lib\npm.js:224:22) at C:\Program Files\nodejs\node_modules\npm\lib\npm.js:262:24 at C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:81:7 at Array.forEach () at C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:80:13 at f (C:\Program Files\nodejs\node_modules\npm\node_modules\once\once.js:25:25) at afterExtras (C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:178:20) at C:\Program Files\nodejs\node_modules\npm\node_modules\mkdirp\index.js:47:53 at C:\Program Files\nodejs\node_modules\npm\node_modules\graceful-fs\polyfills.js:284:29 at FSReqWrap.oncomplete (fs.js:152:21) C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:205 if (npm.config.get('json')) { ^

ericnewton76 commented 6 years ago

Considering this isnt the right place to report this... Asp.net is not Dotnet...

Your error clearly has nothing to do with DotNet, and more so looks like an error within some npm package