Note that there are some explanatory texts on larger screens.

plurals
  1. PORequestVerificationToken does not match
    primarykey
    data
    text
    <p>I have a problem with the anti CRSF MVC mechanism. The cookie and the form input returned does not match. I'm getting an error every single time, only in one specific page. In the rest of the application it works well.</p> <p>The server is returning <code>HTTP 500 Internal Server Error</code> and I can see on the log this exception:</p> <blockquote> <p>[System.Web.Mvc.HttpAntiForgeryException]: {"A required anti-forgery token was not supplied or was invalid."}</p> </blockquote> <p>This is the hidden input that the server is generating is:</p> <pre><code>&lt;input name="__RequestVerificationToken" type="hidden" value="QK8P7rjyZE6Vm5seY7Fr704YCOoFGdTIMzl1W7R0ZFpXSMjGKLG2T05DfFSYTxvtQCEx7DDT69DGsDB2+ZXFHY8oAjiKz0gw8BhDFywgmfIpoXnGpj7fONNzIIfvbrDrE9WJsMu6Io/0bDLM5WfKs0zktiNjyOWpfYrmnfINYmjW8NLOZFoz74xTcgTptAld"&gt; </code></pre> <p>And this is the Cookie returned:</p> <pre><code>Set-Cookie:__RequestVerificationToken_L2VGbG93=skmTAVI8HCbfxDS+xhioIMIISL3UOBI7qJM1JbHjTtAqKl4W70pDUcTKMm0p3R3mrHDziE8vXw0C0OO4HArzWO1/e6py+v/cFdbe9maFgjl4jMiZ9Wc4YIhC6+IUXkk6yqJDJ8dCIr8qtGaYcD9IX+m7/SlVhu521KQSWJYRcaY=; path=/; HttpOnly </code></pre> <p>When I examine what the server is sending, the cookie is exactly the same, but the payload has different encoding I think:</p> <pre><code>__RequestVerificationToken:QK8P7rjyZE6Vm5seY7Fr704YCOoFGdTIMzl1W7R0ZFpXSMjGKLG2T05DfFSYTxvtQCEx7DDT69DGsDB2%2BZXFHY8oAjiKz0gw8BhDFywgmfIpoXnGpj7fONNzIIfvbrDrE9WJsMu6Io%2F0bDLM5WfKs0zktiNjyOWpfYrmnfINYmjW8NLOZFoz74xTcgTptAld </code></pre> <p>The differences are in two characters that appear encoded:</p> <pre><code> / -&gt; %2F + -&gt; %2B </code></pre> <p>Those are the only differences I can find between the hidden input field, and the post payload. </p> <p>What could be the problem that is causing that <code>ValidateAntiForgeryToken</code> fails in verify the token?</p> <p>Regards.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload