Anti forgery token and web testing

后端 未结 3 718
渐次进展
渐次进展 2021-02-09 18:16

I am trying to do a web test in VS2012 for an MVC site. One of the scenarios is to login and go through a list of products, select the one you want and follow through to the pu

3条回答
  •  南旧
    南旧 (楼主)
    2021-02-09 18:49

    I was seeing a similar problem. After recording a web test script, the script would fail at the point of log-in on with the following message:

    The provided anti-forgery token was meant for user "Domain\UserName", but the current user is "".

    The solution was to set the PreAuthenticate property to false in the test properties. By default the web tests will pass an authentication header to the server which was being used in the generation the token.

提交回复
热议问题