Anyone have experience with the ASP.NET Core React + Redux template? Looking for some help with it.
Hey guys, so as the title says, I'm working with the React/Redux ASP.NET Core 2.1 project template. I'm trying to tie it into an in-house OAuth service, so when the app initially loads, it checks to see if the oauth token exists in the session. If it doesn't exist yet, it'll redirect to continue onto the oauth flow to get the token. Once the token is received, it'll store it in the session, and (this is where my problem is) redirect the user to the React part of the app. That all happens on the server side.
So here's my problem: I'm not able to redirect the user back to the client. The app loads, it sees that the token doesn't exist in the server session, it redirects to the oauth flow, the user signs in, the user is redirected back to the app (the controller), and the token is saved in the session. At this point I need to redirect them back to the actual client-side, but if I do something like return Redirect("/");, I get an error stating that no "Index.cshtml" could be found. And that makes sense because of how this project is set up by default. There is no Index.cshtml like I would expect to render the React app.
That being the case, how can I redirect them back to the client? I've done similar flow in another app that was built more from scratch and in that app I was able to just return return RedirectToAction("Home", "Index"); after I saved my token in the session. The Home/Index.cshtml in that case was what rendered the React app, so it was easy enough. But since this new project doesn't have an Index.cshtml, so I'm not really sure how to proceed.
Thanks in advanced for the help.
Edit: One workaround I have, which is not ideal, is to redirect to a different route that isn't the base URI. So instead of doing return Redirect("/"), I can do return Redirect("someRoute"). As long as the someRoute is configured in my react router, it'll actually redirect properly to that page. Then in that page's component, in the componentWillMount, I immediately redirect them to the base URI ("/)". It's really not an ideal solution though.
0 comments:
Post a Comment