Last post Mar 08, 2018 09:28 PM by mikeward
Mar 08, 2018 09:28 PM|mikeward|LINK
I'm trying to get a form submit to work with Razor Pages. It never hits my OnPost() routine. I stubbed in an OnGet() method temporarily and it executed. Stumped as to why the OnPost doesn't work. Code is at https://github.com/mike-ward/SampleCore.
REAME.md has build instructions. It's a very basic project so not much is required.
I've tried several different signatures for OnPost without luck. I have to be missing obvious is all I can figure.
Mar 09, 2018 03:05 AM|mikeward|LINK
OK, I figured out what's happening. There's an AntiForgery Token that needs to be supplied for all post requests. I'm coming from a different framework (NancyFX) where this was handled (I assume) automatically.
Since I'm generating the form client side it requires embedding a token in the layout where it can be found and added to the form. Sorry if anyone as wasted their time on this. Coming from NancyFX, some of the ASP.NET stuff is new to me.
I found this article to be quite helpful.