0

有人可以告诉我如何将 asp.net cookie 授权添加到请求标头(通过 MVC3)吗?

曲奇饼:

Cookie: __RequestVerificationToken_Lw__=8+WZPGAaKtgkIPfbBovP1ZRP2qQKE3u67ueltnzcoCPH0nN1tUHdtgUorjlweUvn+zTJhkFeRuMShCOrbyHR5Xi3DOL4HCspXuVEOsWIr4Ape+l5MYPiFsQ6Lnw8LstqNjceWW9EaV24eA0mVxq2xTG18h/INNKLB8cRUiEn9DI=; .ASPXAUTH=C64A69436A8FC4A6DF5BC222982030C3CCF9E43FBCE335A47173236B4BA4B1CE762CBE6C9E9FDBB035D46C8F36228A61117F22DD55CF787D5E23A728F68B49DDF1A5D70FF3D33C8D16B06FC81894201E86DF93754B6021C9031CB4FBC5236DED952FB7244CE3217B659325A0614763B2E123002E5291EE8D8CEA7B2D7441F3EBB8176A71CDD6FEF3E545CDF46858174451D38890861664A55AF681A36C0B7CF1

实际请求的片段:

Accept: text/*
Content-Type: multipart/form-data; boundary=----------KM7Ij5Ij5ei4gL6KM7ae0cH2Ef1ae0
User-Agent: Shockwave Flash
Host: localhost:82
Content-Length: 36874
Connection: Keep-Alive
Pragma: no-cache
Cookie: __RequestVerificationToken_Lw__=8+WZPGAaKtgkIPfbBovP1ZRP2qQKE3u67ueltnzcoCPH0nN1tUHdtgUorjlweUvn+zTJhkFeRuMShCOrbyHR5Xi3DOL4HCspXuVEOsWIr4Ape+l5MYPiFsQ6Lnw8LstqNjceWW9EaV24eA0mVxq2xTG18h/INNKLB8cRUiEn9DI=; .ASPXAUTH=C64A69436A8FC4A6DF5BC222982030C3CCF9E43FBCE335A47173236B4BA4B1CE762CBE6C9E9FDBB035D46C8F36228A61117F22DD55CF787D5E23A728F68B49DDF1A5D70FF3D33C8D16B06FC81894201E86DF93754B6021C9031CB4FBC5236DED952FB7244CE3217B659325A0614763B2E123002E5291EE8D8CEA7B2D7441F3EBB8176A71CDD6FEF3E545CDF46858174451D38890861664A55AF681A36C0B7CF1

------------KM7Ij5Ij5ei4gL6KM7ae0cH2Ef1ae0
<more stuff here...>
4

1 回答 1

2

你没有。设置 cookie 时,会在每个请求中自动提供 cookie。

您使用 FormsAuthentication 类设置 cookie。通常,这看起来像这样:

 FormsAuthentication.SetAuthCookie(model.UserName, false /*createPersistentCookie*/);
于 2012-04-20T21:54:37.887 回答