Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7507143
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T22:25:43+00:00 2026-05-29T22:25:43+00:00

i read about how to use the <@Html.AntiForgeryToken()> to generate an encrypted value in

  • 0

i read about how to use the <@Html.AntiForgeryToken()> to generate an encrypted value in a hidden field, which will also match another value that is stored as a session cookie in the user’s browser.

But my questions are:-
1. will the value in the session cookie be encrypted also,
2. and if yes then how the [ValidateAntiforgeryToken] on the action controller will know how to decrypt both values and match them?

BR

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T22:25:43+00:00Added an answer on May 29, 2026 at 10:25 pm

    will the value in the session cookie be encrypted also

    Yes. It represents a token. And it’s the same value as the one used for the hidden field. Actually it’s the Html.AntiForgeryToken() helper that does 2 things. It generates the token and puts renders it in a hidden field and it also sets a cookie with the same value.

    and if yes then how the [ValidateAntiforgeryToken] on the action controller will know how to decrypt both values and match them?

    It uses the same encryption/decryption algorithm that classic WebForms use to encrypt/decrypt ViewState. It’s a symmetric encryption algorithm based on the machine keys. That’s why if you are running in a web farm you should ensure that you have the same machine keys across all nodes because if an anti forgery token was generated and encrypted on one node of the web farm it might not be able to be decrypted on another node when the POST request is sent if the machine keys do not match.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Everything I read about better PHP coding practices keeps saying don't use require_once because
I read about ContactsContract.CommonDataKinds.GroupMembership , but I can't figure out what URI use to
I've read about the svn move command but haven't been able to use it
Ok, I've read the articles about why it's a better idea to use an
I read all over the place about how Spring encourages you to use interfaces
I read about small talk being completely object oriented.. is C++ also completely object
I have read about Java enums and use them regularly. However, I don't understand
ih ave read about the technique to allow dynamic HTML stylesheets using PHP's preprocessor,
Read about Server push here . I want to push data to client from
I read about the Conditional attribute today. According to MSDN: Applying ConditionalAttribute to a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.