score:2
In order to have a client router that works with both client navigation and direct navigation (like browser bookmark, shared links ans seo) you need to configure a fallback in your server in order to serve index.html (witch will manage client routing)
This becouse brower doesn’t know in which part of your application is routing managed.
If static file are managed by a static server (or if you are behind a reverse proxy) such as nginx you need to use try_files, like that https://stackoverflow.com/a/35039350.
If your static files are managed by your .net application probably you’ll need to configure a default route such as https://stackoverflow.com/a/24564360
During the migration new uri will be resolved as follows:
- server side routing
- fallback to client side routing
Href inside the application will be resolved as follows:
- client side routing
- fallback to server side routing.
score:0
You could add each of the .Net routes to your React router config that reloads when landing on each - something like:
<Route path="/my-dot-net-page" component={ReloadComp} />
Where ReloadComp looks something like:
const ReloadComp: React.FC<RouteComponentProps> = props => (window.location.href = props.location.pathname);
This will cause a reload when landing on each of those routes and it should let your .Net webserver handle the route.
Alternatively I think it might be worth holding back on react-router until you move the whole project across to React.
What are you trying to get from it at the moment?
If you are after navigation without full reloads it will not work between the React pages and your .Net pages - a reload will be required.
Once all the views are in React making the change to react-router will be simpler
Source: stackoverflow.com
Related Query
- Browser History not working when going back in react-router-dom
- react router dom not working when changing the path
- React Router V4 Browser Back not working
- Link props when passed does not work when browser back and forth is clicked React router v4
- External link not working when using LINK from react router dom
- Call back not working when Link is clicked in react router
- React Router dom is not working when I hosted my React App with github pages?
- React Router BrowserRouter leads to "404 Not Found - nginx " error when going to subpage directly without through a home-page click
- React Router with custom history not working
- React router not showing browser history
- React router browser back button isn't working
- React Router Dom v4 handle browser back button
- Reactjs react router dom useParams not working with dynamic url
- React router v4 broswer history not working with code splitting
- React Router not working when URL contains multiple paths
- Redirect in React Router not working when I click from Users to Post
- React router dom (6.0.1) child route not working properly
- Nested Route not working in react router dom for my admin dashboard
- React router No Match 404 not working when deployed?
- React Router V5 not rendering route when clicking Link, but back and forward buttons work?
- How to controling browser back button with react router dom v6?
- React router dom navigate method is not working properly
- URL params have not updated yet when we listent to history in react router
- How to fix "TypeError: Object(...) is not a function" when using a wrap function on React Component to authenticate user login with Browser Router
- react router not working and no erros in console or compilation error is shown [ react router dom v5]
- React router DOM : Switch not working if child element isnt a route
- React Router Dom NavLink and Link not Working
- Handle browser back button with React router dom
- React Router going back two pages while preserving history
- How to re-render or refresh previous screen when going back using react router flux
More Query from same tag
- How to filter object from one key only and return it as json?
- Change URl without page refresh NEXT.JS
- How to manage components/widgets which can be added/removed dynamically by the end user
- border radius of a div inside another div is overlapping
- React Material UI OutlinedInput does not display error message
- How to add a form input on a Dialog from Show view with React Admin?
- Reactjs save state after refresh
- Why do I have to refresh page manually after delete?
- Passing all state properties to function except one
- How to stop auto re-render on components by using useEffect hook?
- useEffect and 'react-hooks/exhaustive-deps' linting
- React type error "not assignable to parameter of type 'never'"
- Loop through object and get random item in javascript
- TypeScript Err: "Element implicitly has an 'any' type because expression of type 'any' can't be used to index type
- React Bootstrap fullscreen prop not working
- How to access material theme in shared component in react?
- log out user when response from api is 401
- displaying a result in render from a function in REACTJS
- Schedule an API call in ReactJS
- Am I missing some code to view this video in a react app using visual studio code [react]
- how call OwlCarousel react Method
- Warning: [antd: Checkbox] `value` is not validate prop, do you mean `checked`?
- how to make parent component pass prop to children only when button is clicked
- Simulate - meant to be run on 1 node. 0 found instead
- My ReactJS/Django(Rest API) prompts an Unhandled Promise rejection when I browse from a different PC on the LAN
- react: using es6 component in ts component: ts2605: jsx element type 'yyy' is not a constructor function for jsx elements
- Getting a Typescript error with useCallback() in Visual Studio Code
- Bootstrap toggle (navbar) is not working on first load React
- How to solve multi type object data in single parameter
- How to ignore the websocket event for the client who made a change via HTTP?