Using AntiForgeryToken on React/Redux Server Side Rendering #624

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

Originally created by @JoshClose on 6/28/2017

I need to use the AntiForgeryToken for form submits. What I do on the client is generate a js variable like this

window.aft = '@Html.AntiForgeryToken()';

I can then do this in pages where I need it.

<div dangerouslySetInnerHTML={{ __html: global.aft }}></div>

When doing server side rendering this isn't possible.

How do you recommend doing this?

My only guess is to use asp-prerender-data. Is there a better way?

*Originally created by @JoshClose on 6/28/2017* I need to use the AntiForgeryToken for form submits. What I do on the client is generate a js variable like this ``` window.aft = '@Html.AntiForgeryToken()'; ``` I can then do this in pages where I need it. ``` <div dangerouslySetInnerHTML={{ __html: global.aft }}></div> ``` When doing server side rendering this isn't possible. How do you recommend doing this? My only guess is to use `asp-prerender-data`. Is there a better way?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/JavaScriptServices#624
No description provided.