4

I am working on a asp.net project with react and want to use react-router. On its git repo the setup is only explained for Node.js. I found the TypeScript packages of NuGet but after installing them, I cannot build my project anymore due to compilation errors.

Does anyone have experience with installing react-router for asp.net projects?

2
  • What are you trying to achieve? You can't run JavaScript Code in server-sided .net Applications. Commented Aug 24, 2016 at 11:53
  • 1
    Doesn't react-router run on the client? Just like react itself? Commented Aug 24, 2016 at 12:03

2 Answers 2

1
+50

What we did to build our application in React. We created our whole application in React in Visual Studio Code with Redux and React-Router. Webpack is used to build all the files. Once whole application is completed, we build the js (transpiled and minified) and added a script tag pointing to that url of the bundle js into our web application page (specifically .aspx page).

Now issues you might face with react-router, if you have hosted it inside a directory of your existing project. For e.g. inside root - you have folder named myapp. If that is the case - you need to make changes to your Routes in your react app to have a base name.

I tried React.NET but after doing it this way - I really liked this approach as you can separately build the whole application with all the awesome tools you have in client side ecosystem - for instance - hot reloading

Hope it helps.

Sign up to request clarification or add additional context in comments.

2 Comments

what about SEO and other benefits of using react.net?
For SEO - you need to do some processing for handling different routes. We have excluded that part for now.
1

I have never used React.NET, but what you can do is create a separate project, outside of your ASP.NET project. Use webpack for bundling and other purposes. Build your react project, which generates static assets (main.js, chunks, css files and images/sprites). Add these generated files in your ASP.NET project directly and set index.html as Start Page.

We have built our React project on top of this boilerplate. It uses industry-grade ways of optimization, uglification, minification, bundling and what not! Good luck!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.