A
A
Alexander Bogdanov2019-06-16 14:10:25
ASP.NET
Alexander Bogdanov, 2019-06-16 14:10:25

How to make React work with its own routing on a separate page of an ASP.NET application?

There is an ASP.NET.MVC application (probably I'm a front-ender - I don't really understand it). There are several pages from the Razor template engine. On one of them I want to tie a SPA on react with internal routing. That is, the server returns the site.com/admin page, and the react is already running on it, in which I configured the router. But the problem is that when you go, for example, to /admin/accounts (available in the router), the server returns 404, because it does not know such a page. I believe that you need to somehow configure it so that for any link that starts with /admin, the server gives the react page and then it understands itself. At the same time, it is important that the rest of the "template" pages do not break and the api too. Found a variant with route supposedly for SPA "routes.MapSpaFallbackRoute("spa-fallback", new { controller = "Home", action = "Index" });" but this did not help, as far as I understood, partly because my page is not indexed and there is no controller for it. Please help me to adapt this correctly for my case. Or maybe there are other options?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vyacheslav Zolotov, 2019-06-16
@SZolotov

See how it works in the template https://docs.microsoft.com/en-us/aspnet/core/clien...

S
Sergey Egorov, 2019-08-24
@SergeyEgorov

...react works on it, in which I configured the router...

That is, you have configured component routing in the React application https://habr.com/en/post/329996/
But at the same time, you have a React application instead of loading a component, pulling the server URL?
Maybe you didn't quite set up the routing in React?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question