Using redirection during prerendering should be supported #1416

Closed
opened 2025-08-09 17:20:03 +00:00 by fergalmoran · 0 comments
Owner

Originally created by @ehaskins on 8/26/2016

I'm implementing some client side-authentication logic in React while using the asp-prerender. Client side this this isn't a problem using react-router's onEnter hook, but when prerender it needs to return 302.

The react-router ServerRendering page shows how to determine if a redirect should occur before doing a complete render, but I don't see any way to actually initiate the redirect.

Is it possible to initiate a 302 from a TagHelper?

For now I can either see two workarounds

  • Disable pre-rendering, and allow the navigation to happen client side
  • Use asp.net routing to redirect before attempting to do the 302, but this seems fragile.

I suspect enabling this is a larger task, but the current error message in the React-Redux template is Exception: Call to Node module failed with error: Error: The location '/' doesn't match any route configured in react-router., which isn't accurate. A more descriptive message would have been very helpful.

*Originally created by @ehaskins on 8/26/2016* I'm implementing some client side-authentication logic in React while using the asp-prerender. Client side this this isn't a problem using react-router's onEnter hook, but when prerender it needs to return 302. The react-router [ServerRendering](https://github.com/reactjs/react-router/blob/master/docs/guides/ServerRendering.md) page shows how to determine if a redirect should occur before doing a complete render, but I don't see any way to actually initiate the redirect. Is it possible to initiate a 302 from a TagHelper? For now I can either see two workarounds - Disable pre-rendering, and allow the navigation to happen client side - Use asp.net routing to redirect before attempting to do the 302, but this seems fragile. I suspect enabling this is a larger task, but the current error message in the React-Redux template is `Exception: Call to Node module failed with error: Error: The location '/' doesn't match any route configured in react-router.`, which isn't accurate. A more descriptive message would have been very helpful.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/JavaScriptServices#1416
No description provided.