Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReactJS .Net CORE #1

Open
fhlee74 opened this issue Jul 16, 2018 · 2 comments
Open

ReactJS .Net CORE #1

fhlee74 opened this issue Jul 16, 2018 · 2 comments

Comments

@fhlee74
Copy link

fhlee74 commented Jul 16, 2018

Can we have a similar repo for ReactJS for .Net Core please? Will be great for dummies like myself.

@xidedix
Copy link
Collaborator

xidedix commented Jul 16, 2018

hi @fhlee74

CoreUI is a standard CRA React app. Therefore basic setup of CoreUI for .NET Core 2.1 using .Net Core 2.1 React project template should be straightforward.

1. Prerequisites:

  • .NET Core 2.1.2 with SDK 2.1.302 installed - SDK Installer
  • Node.js, version 8.11 or later
  • code editor of your choice (if you prefer Visual Studio you need to use version 2017 15.7.x or newer)

2. Create a new app

  • in an empty directory create a new project from a command prompt dotnet new react
  • remove sample application directory rd ClientApp /S /Q
  • clone CoreUI repo: git clone https://github.com/coreui/coreui-free-react-admin-template CoreUI
  • edit react.csproj and modify <SpaRoot>ClientApp\</SpaRoot> to <SpaRoot>CoreUI\</SpaRoot>
  • edit startup.cs and modify:
    configuration.RootPath = "ClientApp/build"; to configuration.RootPath = "CoreUI/build";
    and spa.Options.SourcePath = "ClientApp"; to spa.Options.SourcePath = "CoreUI";

3. Build and run

  • from Visual Studio open the .csproj file, and run the app (the build process restores npm dependencies on the first run)
  • or from .NET Core CLI
    • Run dotnet build
    • Run dotnet run to start the app

See also: https://docs.microsoft.com/en-us/aspnet/core/client-side/spa/react?view=aspnetcore-2.1&tabs=netcore-cli

@rachelfreeman
Copy link

@xidedix with that type of setup for the startup.cs SourcePath and RootPath, I'm randomly getting the following error on my dev server: "Exception":"System.InvalidOperationException: The SPA default page middleware could not return the default page '/index.html' because it was not found, and no other middleware handled the request.\nYour application is running in Production mode, so make sure it has been published, or that you have built your SPA manually. Alternatively you may wish to switch to the Development environment.

Any ideas? Everything I am finding is saying it's because the RootPath and SourcePath can't find the page, but most of the time it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants